diff options
Diffstat (limited to 'en/downloads/get/lib.php')
-rw-r--r-- | en/downloads/get/lib.php | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/en/downloads/get/lib.php b/en/downloads/get/lib.php index 65baa10a3..cb15c423d 100644 --- a/en/downloads/get/lib.php +++ b/en/downloads/get/lib.php @@ -162,4 +162,32 @@ function get_download_link($product, $torrent_preferred = false) } return '$MIRROR/' . $path; -}
\ No newline at end of file +} + +/** + * Builds human readable list from array with l10n option + * + * @param array $array to build the string from + * @param string $last_separator flexible (l10n) last separator + * @param string $nonlast_separator flexible (l10n) other than last separators + * + * @return string +*/ +function array_to_list($array, $last_separator = ' and ', $nonlast_separator = ', ') +{ + $num_of_values = count($array); + $output_string = ''; + $separator = $nonlast_separator; + foreach ($array as $value) { + $output_string .= $value; + if ($num_of_values == 2) { + $separator = $last_separator; + } else if ($num_of_values == 1) { + $separator = ''; + } + $output_string .= $separator; + $num_of_values--; + } + + return $output_string; +} |