Home > Backend Development > PHP Tutorial > How to call when the key name of json is a number (sample code)_PHP tutorial

How to call when the key name of json is a number (sample code)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:25:12
Original
978 people have browsed it

When the key name is a number or an abnormal variable character (if there is a space), the obj[xx] method must be used to obtain the value.

Copy code The code is as follows:

//Declare json data
$array = array('result'=>array("90"=>"90 queue","status"=>"Success"));
$json = json_encode($array);

$array1 = array("90"=>"90 Queue","status"=>"Success");
$json1 = json_encode($array1);
$phpjson = json_decode( $json1,true);//The second parameter is true, which means converting json data into an array
//When the json key name is a number, it can only be processed in array mode $phpjson['90'];
?>









www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825157.htmlTechArticleFor key names with numbers or abnormal variable characters (if there are spaces), obj[xx] must be used Get the value. Copy the code The code is as follows: ?php //Declare json data $array = array('res...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Backslash present in Json
From 1970-01-01 08:00:00
0
0
0
Get: Transfer JSON data
From 1970-01-01 08:00:00
0
0
0
mysql storage json error
From 1970-01-01 08:00:00
0
0
0
javascript - Problems with displaying json data
From 1970-01-01 08:00:00
0
0
0
Find matching integers in JSON.
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template