Home  >  Article  >  Backend Development  >  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

WBOY
WBOYOriginal
2016-07-13 10:25:12914browse

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