In the documentation for preg_replace it says you can use indexed arrays to replace multiple strings. I would like to do this with associative arrays, but it seems to not work.
Does anyone know if this indeed does not work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you want to do this on keys or the keys and values or just retain the keys and process the values? Whichever the case,
array_combine(),array_keys()andarray_values()can achieve this in combination.On the keys:
On the keys and values:
On the values retaining keys:
All of these assume a function something like: