为什么我不能对数组进行json_decode?
下面的代码有"''w",当我使用json_decode时,php返回null值,为什么?我该怎么修?
<?php
$str='[0,"^('w)+$","Your email is unvailable"]';
$arr= json_decode($str,true);
var_dump($arr); // null
在JSON中的字符串中,反斜杠必须转义;您想要(演示)
$str = '[0,"^(''''w)+$","Your email is unvailable"]';
需要有四个反斜杠,因为php字符串文字也需要转义反斜杠。