how to show arraylist in comma separated with last and in php

92

$last_element = array_pop($number_list);
array_push($number_list, 'and '.$last_element);

Then you can do your implode:

$comma_list = implode(', ', $number_list);
$last_element = array_pop($number_list);
array_push($number_list, 'and '.$last_element);

Comments

Submit
0 Comments