您好,欢迎访问一九零五行业门户网

CURL后的结果解析成数组有关问题

curl后的结果解析成数组问题
index.php,echo json_encode后的结果为:
{11:{l_id:11,l_title:cits-香港观光一天游【品质纯玩】},12:{l_id:12,l_title:test}}
然后客户端代码(client.php)如下:
$curlpost='key='.urlencode($key);
$ch=curl_init();
curl_setopt($ch,curlopt_url,'http://www.cits-sz.net/api/index.php');
curl_setopt($ch,curlopt_header,0);
curl_setopt($ch,curlopt_returntransfer,true);
curl_setopt($ch,curlopt_post,1);
curl_setopt($ch,curlopt_postfields,$curlpost);
$data=curl_exec($ch);
curl_close($ch);
echo json_decode($data,true);

得到的结果也是
{11:{l_id:11,l_title:cits-香港观光一天游【品质纯玩】},12:{l_id:12,l_title:test}}
请问要如何才能将其变成如下的方式呢,谢谢了
array
(
[11] => array
(
[l_id] => 11
[l_title] => cits-香港观光一天游【品质纯玩】
)
[12] => array
(
[l_id] => 12
[l_title] => test
)
)
------解决方案--------------------
那你就再 json_decode 一次
$s = '{11:{l_id:11,l_title:cits-香港观光一天游【品质纯玩】},12:{l_id:12,l_title:test}}';
print_r(json_decode($s,1));
array
(
[11] => array
(
[l_id] => 11
[l_title] => cits-香港观光一天游【品质纯玩】
)
[12] => array
(
[l_id] => 12
[l_title] => test
)
)

其它类似信息

推荐信息