I have a string that when I var_dump returns the following
string(20) \"{\\\"key1\\\":\\\"key1_value\",\\\"key2\\\":\\\"key2_value\\\"}\"
How c
The explode function will get you what you need.
explode(',\\',$string);
should do the trick.
It looks like a simple JSON array that got mangled by PHP's magic_quotes
or some other escaping function. Turn off magic_quotes
and run json_decode()
on the string.
// If you cannot disable `magic_quotes` or you escaped it manually, use this
$array = json_decode(stripslashes($strings), true);
What you have as data looks like valid JSON. You probably can use json_decode with the second parameter to true (to get an associative array) like this:
$array = json_decode($string, true);