note 99233 deleted from function.implode by danbrown
| From: | danbrown@php.net | Date: | Thu, 05 Aug 2010 13:29:59 +0000 |
| Subject: | note 99233 deleted from function.implode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171396@lists.php.net to get a copy of this message | ||
Note Submitter: peterjwest3 at gmail dot com
----
This is a slightly more flexible and concise version of pr at technoparkcorp's
ImplodeToEnglish() function. Works for any length array, but doesn't check for other types.
<?php
function implodeWithFinal($list, $separator = ", ", $final = " and ") {
$last = array_pop($list);
return (count($list) ? implode($separator, $list).$final : null).$last;
}
?>