note 109570 added to function.implode
| From: | thepseudo06 at gmail dot com | Date: | Mon, 30 Jul 2012 04:16:02 +0000 |
| Subject: | note 109570 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189458@lists.php.net to get a copy of this message | ||
I made a function kind of like implode that begins imploding after a certain amount of indexes/keys
have been passed.
<?php
function intplode(array $pieces, $glue, $start){
if(!is_array($pieces)) return 0;
if(!is_numeric($start)) return 0;
$loop = 0;
foreach($pieces as $index=>$value){
unset($pieces[$index]);
if(++$loop == $start){
return implode($glue, $pieces);
}
}
}
echo intplode(array('a', 'b', 'c', 'd'), ' ', 1);
?>
Will output "b c d".
----
Server IP: 69.147.83.197
Probable Submitter: 109.163.233.200
----
Manual Page -- http://www.php.net/manual/en/function.implode.php
Edit -- https://master.php.net/note/edit/109570
Del: integrated -- https://master.php.net/note/delete/109570/integrated
Del: useless -- https://master.php.net/note/delete/109570/useless
Del: bad code -- https://master.php.net/note/delete/109570/bad+code
Del: spam -- https://master.php.net/note/delete/109570/spam
Del: non-english -- https://master.php.net/note/delete/109570/non-english
Del: in docs -- https://master.php.net/note/delete/109570/in+docs
Del: other reasons-- https://master.php.net/note/delete/109570
Reject -- https://master.php.net/note/reject/109570
Search -- https://master.php.net/manage/user-notes.php