Re: [PATCH] New function implode_multi
| From: | Markus Fischer | Date: | Fri, 07 Jun 2002 09:02:45 +0000 |
| Subject: | Re: [PATCH] New function implode_multi | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-84975@lists.php.net to get a copy of this message | ||
Hi,
On Fri, Jun 07, 2002 at 10:49:21AM +0200, C. McCohy wrote :
> <?
> $fruits = array('banana', 'orange', 'apple');
> $vegetables = array('carrot', 'cabbage', 'cucumber');
> $favorite_food = 'icecream';
>
> $all_day_food = implode_multi(', ', $fruits, $vegetables, $favorite_food);
> // ... = "banana, orange, apple, carrot, cabbage, cucumber, icecream"
> ?>
Do we really need a new function just to save a few
keystrokes? Using array_merge() can you achive the same
thing:
<?
$fruits = array('banana', 'orange', 'apple');
$vegetables = array('carrot', 'cabbage', 'cucumber');
favourite_food = 'icecream';
$foo = implode(', ', array_merge($fruits, $vegetables, array($favourite_food)));
var_dump($foo);
?>
$ php test2.php
string(58) "banana, orange, apple, carrot, cabbage, cucumber, icecream"
- Markus
--
GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc