Skip to content

Instantly share code, notes, and snippets.

@mikehins
Last active December 8, 2016 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehins/15a249d35a31b80713f9a9e709da9d49 to your computer and use it in GitHub Desktop.
Save mikehins/15a249d35a31b80713f9a9e709da9d49 to your computer and use it in GitHub Desktop.
Replace value inside a json string with regex
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