note 52371 deleted from function.implode by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 13:16:03 +0000 |
| Subject: | note 52371 deleted from function.implode by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189719@lists.php.net to get a copy of this message | ||
Note Submitter: tshort at cisco dot com
----
/*
english_list()
This one works with anything, since the array is passed by reference, modifying it in the function
via pop has no effect on the array outside the function. But it can't be done on one line,
because the array_pop() must occur before the join().
*/
function english_list($array, $oxfordComma=0)
{
$last = array_pop($array);
return join(", ", $array) . ($oxfordComma ? "," : "") . " and
" . $last;
}