note 94688 added to function.implode
| From: | mwwaygooAThotmailDOTcom at osu1 dot php dot net | Date: | Wed, 18 Nov 2009 15:54:27 +0000 |
| Subject: | note 94688 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163037@lists.php.net to get a copy of this message | ||
I was a little worried about the multi-dimensional array implodes listed here, as they are using
'for' loops, which is bad programming practice as arrays are not always nice and neat.
I hope this helps
<?php
function multi_implode($glue, $pieces)
{
$string='';
if(is_array($pieces))
{
reset($pieces);
while(list($key,$value)=each($pieces))
{
$string.=$glue.multi_implode($glue, $value);
}
}
else
{
return $pieces;
}
return trim($string, $glue);
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 84.12.100.124
----
Manual Page -- http://www.php.net/manual/en/function.implode.php
Edit -- https://master.php.net/note/edit/94688
Del: integrated -- https://master.php.net/note/delete/94688/integrated
Del: useless -- https://master.php.net/note/delete/94688/useless
Del: bad code -- https://master.php.net/note/delete/94688/bad+code
Del: spam -- https://master.php.net/note/delete/94688/spam
Del: non-english -- https://master.php.net/note/delete/94688/non-english
Del: in docs -- https://master.php.net/note/delete/94688/in+docs
Del: other reasons-- https://master.php.net/note/delete/94688
Reject -- https://master.php.net/note/reject/94688
Search -- https://master.php.net/manage/user-notes.php