I have a string of that displays like this:
1235, 3, 1343, 5, 1234, 1
I need to replace every second comma with a semicolon
i.e.
1235, 3; 1343, 5; 1234, 1
The string length will always be different but will follow the same pattern as the above i.e. digits comma space digits comma space, etc.
How can I do this with PHP? Is it possible?
Thanks.
$replaced = preg_replace('/(.*),(.*),/', '$1,$2;', $strToReplace);And I agree with @deceze. You should try to solve your problems on your own./(.*?),(.*?),/instead of/(.*),(.*),/.