日期:2014-05-17 浏览次数:20566 次
<?php $json='{"id":"0100","regionList":[{}],"pinyin":"beijing"}'; print_r(json_decode($json,true));
------解决方案--------------------
正则法:
$s='{"id":"0100","regionList":[{JSON数据}],"pinyin":"beijing"}'; preg_match('/id":"(.*?)".+?pinyin":"(.*?)"/',$s,$m); echo $m[1]; echo $m[2];
------解决方案--------------------
$json='{"id":"0100","regionList":[{}],"pinyin":"beijing"}';
$myArray = json_decode($json,true);
echo $myArray['id'];//输出的就是0100
echo $myArray['pinyin'];//输出的就是beijing