generic preg_replace
Posted: Tue Jan 19, 2010 2:23 am
string1:
string2:
string3:
string4:
So its always \w+,[0-9]+
I would like to convert the strings into:
1: employee_id=13
2: employee_id=13 AND status_id=35
3: employee_id=13 AND status_id=35 AND menu_id = 4
with one and the same expression
for string 1 it would be:
But I have a hard time making it generic for an x number of parameter additions
Any suggestions?
Code: Select all
employee_id, 13Code: Select all
employee_id, 13, status_id, 35Code: Select all
employee_id, 13, status_id, 35, menu_id, 4Code: Select all
etc..I would like to convert the strings into:
1: employee_id=13
2: employee_id=13 AND status_id=35
3: employee_id=13 AND status_id=35 AND menu_id = 4
with one and the same expression
for string 1 it would be:
Code: Select all
preg_replace('(\w+),([0-9]+)','$1=$2 ' $string);Any suggestions?