How to add comma (,) and AND (&) atlast using implode
Hi, I see many of them will be thinking how to display array values with comma but to display last one as &. Here is the code where it will list all the array values with comma separated but last value it will replace &. $arr = array('red','pink','blue','violet'); $last = array_pop($arr); $string = count($arr) ? implode(", ", $arr) . "& " . $last : $last; Output: ------------ red, pink, blue &violet Hope this will be useful.