Javascript-php reads the json file and searches for the content.

Source: Internet
Author: User
Is there a json file x. json now php wants to read the content of the json file and search for items in the bundle as required. For example, how can I find the corresponding output for the dkey output through A03? Ask for advice! Error


Is there a json file x. json?

In php, you want to read the content of the json file and search for items in the bundle as required.
For example, the dkey value is output through A03.
How can I find the corresponding output? Ask for advice!

Error

Reply content:


Is there a json file x. json?

In php, you want to read the content of the json file and search for items in the bundle as required.
For example, the dkey value is output through A03.
How can I find the corresponding output? Ask for advice!

Error

Your json file has a bom header,

$json = file_get_contents('Qcode.json');$arr = json_decode(trim($json, chr(239) . chr(187) . chr(191)), true);$temp = array_column($arr, 'dkey', 'dvalue');echo $temp['A05'];if (! function_exists('array_column')) {    function array_column(array $input, $columnKey, $indexKey = null)    {        $array = array();        foreach ($input as $value) {            if (! isset($value[$columnKey])) {                trigger_error("Key \"$columnKey\" does not exist in array");                return false;            }            if (is_null($indexKey)) {                $array[] = $value[$columnKey];            } else {                if (! isset($value[$indexKey])) {                    trigger_error("Key \"$indexKey\" does not exist in array");                    return false;                }                if (! is_scalar($value[$indexKey])) {                    trigger_error("Key \"$indexKey\" does not contain scalar value");                    return false;                }                $array[$value[$indexKey]] = $value[$columnKey];            }        }        return $array;    }}

Var_dump (json_decode ($ json ));

Print out all the values first and you will know how to call them.

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.