note 85691 deleted from function.implode by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 13:21:06 +0000 |
| Subject: | note 85691 deleted from function.implode by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189758@lists.php.net to get a copy of this message | ||
Note Submitter: Kerberos
----
Here's my version of the english implode function, it's quite crafty so I thought I'd
share it...
<?php
#
# Transforms an array to an english list:
# This, This and This
#
function array_to_english ( $list, $glueword='and' ) {
$string = false;
foreach ( array_reverse ( $list ) as $index=>$value ) {
$string = "$value$glue$string";
if ( $index == 0 ) $glue = " $glueword ";
if ( $index == 1 ) $glue = ', ';
}
return $string;
}
?>