Answer the question
In order to leave comments, you need to log in
How to replace individual values in a json string?
i have a json string
{"ops":[{"url":"site.com/100/test"},{"url":"site.com/200/test"}]}
{"ops":[{"url":"site.com/1000/test"},{"url":"site.com/2000/test"}]}
Answer the question
In order to leave comments, you need to log in
$json = '{"ops":[{"url":"site.com/100/test"},{"url":"site.com/200/test"}]}';
$json = str_replace([100, 200], [1000, 2000], $json);
echo $json;
//{"ops":[{"url":"site.com/1000/test"},{"url":"site.com/2000/test"}]}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question