$json_arr = array('WebName'=>'PHP网站开发教程网','WebSite'=>'http://www.jb51.net');<wbr></wbr>
$php_json = json_encode($json_arr);<wbr></wbr>//把php数组格式转换成 json 格式的数据
echo $php_json;<wbr></wbr>
$php_json = json_decode($php_json);<wbr><wbr></wbr></wbr>//再把json格式的数据转换成php数组
print_r($php_json);
-------------------------------------------------------------------------
json数组
$json = '[{"id":"22","name":"33","descn":"44"}]';<wbr><wbr><span></span>//json格式的数组转换成 php的数组<br> $arr = (Array)json_decode($json);<wbr><br><wbr>echo $arr[0]->id;<wbr><span></span>//用对象的方式访问</wbr></wbr></wbr></wbr></wbr>
$php_json = json_encode($json_arr);<wbr></wbr>//把php数组格式转换成 json 格式的数据
echo $php_json;<wbr></wbr>
$php_json = json_decode($php_json);<wbr><wbr></wbr></wbr>//再把json格式的数据转换成php数组
print_r($php_json);
-------------------------------------------------------------------------
json数组
$json = '[{"id":"22","name":"33","descn":"44"}]';<wbr><wbr><span></span>//json格式的数组转换成 php的数组<br> $arr = (Array)json_decode($json);<wbr><br><wbr>echo $arr[0]->id;<wbr><span></span>//用对象的方式访问</wbr></wbr></wbr></wbr></wbr>