PHP string to array

后端 未结 4 820
北荒
北荒 2021-01-25 11:45

I have a string that when I var_dump returns the following

string(20) \"{\\\"key1\\\":\\\"key1_value\",\\\"key2\\\":\\\"key2_value\\\"}\"

How c

4条回答
  •  别那么骄傲
    2021-01-25 12:40

    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);
    

提交回复
热议问题