This is my first attempt at arrays and using the function pc_array_to_comma_string.
Here is my code:
<?
$array = array('Scott', 'clif', 'leslie', 'mary', 'ashley', 'poop');
function pc_array_to_comma_string($array) {
switch (count($array)) {
case 0:
return'';
case 1:
return reset($array);
case 2:
return join(' and ' , $array);
default:
$last = array_pop($array);
return join(', ', $array) . ", and $last";
}
}
?>
What am I doing wrong? I am getting no results....I was anticipating a string seperated by ,