PHP remove all occurrences of string except last with preg_replace
While trying to manipulate a string in PHP, I ran into a road block trying to remove all instances of “.” and replace with a comma with the exception of the last instance of the period.