PHP parsing JSON data, PHP parsing json_php tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.