note 82415 added to function.join
| From: | tobias at dcode dot se | Date: | Wed, 09 Apr 2008 22:48:45 +0000 |
| Subject: | note 82415 added to function.join | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138084@lists.php.net to get a copy of this message | ||
Why do not this type of function exists or have I missed something?
<?php
/**
* Extended join with max option and end delimiter
*
* @param array $pieces
* @param int $max
* @param string $glue
* @param string $end
* @return string
*/
function join_max($pieces=array(), $max, $glue=', ', $end='')
{
$a = array();
foreach($pieces as $piece) {
if (count($a) <= $max) array_push($a, $piece);
}
return join($glue, $a) . $end;
}
?>
----
Server IP: 212.63.193.10
Probable Submitter: 83.227.108.81
----
Manual Page -- http://www.php.net/manual/en/function.join.php
Edit -- https://master.php.net/note/edit/82415
Del: integrated -- https://master.php.net/note/delete/82415/integrated
Del: useless -- https://master.php.net/note/delete/82415/useless
Del: bad code -- https://master.php.net/note/delete/82415/bad+code
Del: spam -- https://master.php.net/note/delete/82415/spam
Del: non-english -- https://master.php.net/note/delete/82415/non-english
Del: in docs -- https://master.php.net/note/delete/82415/in+docs
Del: other reasons-- https://master.php.net/note/delete/82415
Reject -- https://master.php.net/note/reject/82415
Search -- https://master.php.net/manage/user-notes.php