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;
}
?>
join
tobias at dcode dot se
10-Apr-2008 06:48
10-Apr-2008 06:48
manbss at yahoo dot co dot in
10-May-2007 12:38
10-May-2007 12:38
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = join(",", $array);
echo $comma_separated; // lastname,email,phone
?>
