["/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg","/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg"]
表单提交上面字符串,
php接收并输出,结果是["/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg","/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg"]
百度了一下,使用stripslashes把反斜杠去掉后使用json_decode()转化,结果为空。
<code>$img=stripslashes($data['img']); $img_list=json_decode($img); $test='["/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg","/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg"]'; //$test内容为输入框里的字符串 if($test == $img) echo 1; //if语句不成立,没有输出1; </code>
是什么情况啊。。。
["/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg","/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg"]
表单提交上面字符串,
php接收并输出,结果是["/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg","/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg"]
百度了一下,使用stripslashes把反斜杠去掉后使用json_decode()转化,结果为空。
<code>$img=stripslashes($data['img']); $img_list=json_decode($img); $test='["/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg","/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg"]'; //$test内容为输入框里的字符串 if($test == $img) echo 1; //if语句不成立,没有输出1; </code>
是什么情况啊。。。
<code><?php function arrayEqual($array1,$array2){ return !array_diff($array1,$array2) && !array_diff($array2,$array1); } </code>
楼主可以了解一下array_diff
stripslashes后var_dump看下,是否是合法的json字串。 是不是有实体的双引号 ?
谢谢@star001007 提醒,其实那个引号不需要过滤,json字符串本来就是需要用""引起来的。提主直接json_decode就可以了
<code><?php $a = "[\"/Public/editor/php/../attached/image/20150115/20150115094109_33178.jpg\",\"/Public/editor/php/../attached/image/20150115/20150115094110_19764.jpg\"]"; $b = json_decode($a); var_dump($b); </code>