Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的unserialize函数会向结果字符串添加额外的斜杠_Php - Fatal编程技术网

php中的unserialize函数会向结果字符串添加额外的斜杠

php中的unserialize函数会向结果字符串添加额外的斜杠,php,Php,这是一个序列化表单: [featureimg520_624] => a:2:{s:9:"image_url";s:47:"2019/05/2019-05-27-06-07-02keerthy-suresh2.jpeg" 取消序列化后,我得到 "image_url":"2019\/05\/2019-05-27-06-07-02keerthy-suresh2.jpeg" 加上额外的反斜杠 我试过条纹睫毛,条纹睫毛,str_替换 但是什么都没用。是谁在添加反斜杠。您可以通过对该函数使用J

这是一个序列化表单:

 [featureimg520_624] => a:2:{s:9:"image_url";s:47:"2019/05/2019-05-27-06-07-02keerthy-suresh2.jpeg"
取消序列化后,我得到

 "image_url":"2019\/05\/2019-05-27-06-07-02keerthy-suresh2.jpeg"
加上额外的反斜杠

我试过条纹睫毛,条纹睫毛,str_替换

但是什么都没用。

是谁在添加反斜杠。您可以通过对该函数使用
JSON\u UNESCAPED\u斜杠
选项来避免它们:

$string = 'a:1:{s:9:"image_url";s:47:"2019/05/2019-05-27-06-07-02keerthy-suresh2.jpeg";}';
$array = unserialize($string);
echo json_encode($array, JSON_UNESCAPED_SLASHES);
输出:

{"image_url":"2019/05/2019-05-27-06-07-02keerthy-suresh2.jpeg"}