I have an array ($number_list) that has a dynamically generated list of values. There will be at least 1 value in the array and no more than 4.
$number_list
Currentl
$number_list = array(4, 5, 6, 7); $comma_list = strrev(implode(strrev(', and'), explode(strrev(','), strrev(implode(', ', $number_list)), 2))); echo 'The list is ' . $comma_list . '.';
Output: The list is 4, 5, 6, and 7.