I have a comma separated list, and would like to remove the first occurrence of 1 from the list, but also removing any extra commas that were separating that value. How would this be done?
This is the string:
$str = '1,1,2,3,4,5,6,7,8,9,10';
I need to replace the first 1 so it looks like this:
$str = '1,2,3,4,5,6,7,8,9,10';
I need to remove the extra commas, because the numbers are linked to the items that display on the page in MySQL DB.
1 Answer