Last active
December 8, 2016 12:52
-
-
Save mikehins/15a249d35a31b80713f9a9e709da9d49 to your computer and use it in GitHub Desktop.
Replace value inside a json string with regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function json_replace($key, $value, $json_string) | |
{ | |
return preg_replace('/"' . $key . '":".*?"/', '"' . $key . '":"' . $value . '"', $json_string); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment