note 72282 deleted from function.implode by felipe
| From: | felipe@php.net | Date: | Mon, 24 Dec 2007 02:13:55 +0000 |
| Subject: | note 72282 deleted from function.implode by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133940@lists.php.net to get a copy of this message | ||
Note Submitter: drewish at katherinehouse dot com
----
Here's a pretty clean version of the english_list:
<?php
function english_list($array) {
switch (count($array)) {
case 0:
return '';
case 1:
return array_pop($array);
default:
$last = array_pop($array);
return implode(', ', $array) . ' and ' . $last;
}
}
?>