php解析json数据,php解析json_PHP教程

WBOY
Lepaskan: 2016-07-13 10:20:58
asal
896 orang telah melayarinya

php解析json数据,php解析json

$data;
$data.="[";
for ($i=0;$i {
$data.="{";

$data.="\"id\":\"" . 110 . "\",";
$data.="\"name\":\"" . 110 . "\",";
$data.="\"original_price\":\""
. 110 . "\",";
$data.="\"sale_price\":\""
. 110 . "\",";
$data.="\"introduce\":\"" . 110
. "\",";
$data.="\"content\":\"" . 110
. "\",";
$data.="\"nums\":" . 110 . "";

$data.="}";
if($i {
$data.=",";
}
}
$data.="]";

 

 

//解析 前提是$data是json格式

$array=array();

$de_json=json_decode($data,true);
//var_dump($de_json);
$count_json = count($de_json);
for ($i = 0; $i {
$array[$i]["id"] = $de_json[$i]['id'];
$array[$i]["name"] = $de_json[$i]['name'];
$array[$i]["original_price"] = $de_json[$i]['original_price'];
$array[$i]["sale_price"] = json_encode($de_json[$i]['sale_price']);

}
var_dump($array);

 

 

?>

php解析json数据的问题,寻找高人指点

PHP有提供对JSON的解析支持,可以使用函数:json_decode

$json_string = {
"status":"Success",
"request":{
"method":"POST",
"parameters":[
{
"name":"email",
"value":"lee.li@fleety.com"
},
{
"name":"apikey",
"value":"ABCDEFG123456"
}
],
"from":"192.168.30.40",
"timestamp":1343285417993
},
"duration":14,
"logon_user":{
"guid":108142,
"email":"lee.li@fleety.com",
"device_number":"UNKNOWN",
"is_male":true,
"role":"USER",
"account_state":"ACTIVE",
"logon_times":19,
"last_logon_time":1343285418001,
"last_logon_by":"EMAIL",
"logon_host":"192.168.30.40",
"logon_token":"43O8NNVC3U8KBI5OT1N07PNZF0C28AGI",
"created_time":1343193738000,
"mobile_phone":"UNKNOWN",
"display_name":"lee.li",
"is_verified":false
}
}
EOT;

$json_object = json_decode($json_string);
echo $json_object->logon_user->guid;
参考资料:cn.php.net/...de.php...余下全文>>
 

PHP解析Json数据的问题们帮帮忙

原始数据就是代码,你需要进行哈希转码啊 至于时间的话转换的话,相关发给你的QQ邮箱 才10分好抠门啊
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/864305.htmlTechArticlephp解析json数据,php解析json ?php $data; $data.="["; for ($i=0;$i20;$i++) { $data.="{"; $data.="\"id\":\"" . 110 . "\","; $data.="\"name\":\"" . 110 . "\","; $data.="\"origi...
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan