84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
$str = 'array("1"=>"给对方","2"=>"发鬼地方","5"=>"","6"=>"发鬼地方","7"=>"发光飞碟");';
参考@oraoto
$str = 'array("1"=>"给对方","2"=>"发鬼地方","5"=>"","6"=>"发鬼地方","7"=>"发光飞碟");'; $s= str_replace(['array(','=>',');'],['{',':','}'],$str); print_r(json_decode($s,1)); Array ( [1] => 给对方 [2] => 发鬼地方 [5] => [6] => 发鬼地方 [7] => 发光飞碟 )
思路:
去掉开头的array(和最后的);,变成:
array(
);
'"1"=>"给对方","2"=>"发鬼地方","5"=>"","6"=>"发鬼地方","7"=>"发光飞碟"'
把=>替换成:,变成:
=>
:
'"1":"给对方","2":"发鬼地方","5":"","6":"发鬼地方","7":"发光飞碟"'
前后加{},变成:
{}
'{"1":"给对方","2":"发鬼地方","5":"","6":"发鬼地方","7":"发光飞碟"}'
上json_decode
json_decode
用正则处理,前提是你的value里面不会有 => 这样的文字
参考@oraoto
思路:
去掉开头的
array(
和最后的);
,变成:把
=>
替换成:
,变成:前后加
{}
,变成:上
json_decode
用正则处理,前提是你的value里面不会有 => 这样的文字