PHP parsing JSON data, PHP parsing JSON
$data;
$data. = "[";
for ($i =0; $i <20; $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 <19)
{
$data. = ",";
}
}
$data. = "]";
The parsing prerequisite is that $data is in JSON format
$array =array ();
$de _json=json_decode ($data, true);
Var_dump ($de _json);
$count _json = count ($de _json);
for ($i = 0; $i < $count _json; $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 parsing JSON data problems, looking for expert guidance
PHP provides parsing support for JSON, you can use the function: 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;
Reference: cn.php.net/...de.php ... Remaining full text >>
PHP parsing JSON data problems help me.
The original data is the code, you need to hash transcoding ah as to the time of the word conversion, the related to your QQ mailbox only 10 points good stingy AH
http://www.bkjia.com/PHPjc/864305.html www.bkjia.com true http://www.bkjia.com/PHPjc/864305.html techarticle PHP parsing JSON data, PHP parsing json php $data; $data. = "["; for ($i =0; $i; $i + +) {$data. = "{"; $data. = "\" id\ ": \" ". 110. "\","; $data. = "\" name\ ": \" ". 110. "\","; $data. = "\" Origi ...