In our daily development work, something will encounter PHP recursive JSON, then we will introduce to you today PHP recursive JSON class code, parse the main function, parse the index array, parse the array of numbers, check whether an array is strictly numeric index.
First download the class library of PHP recursive JSON that we need to use for this lesson: http://www.php.cn/xiazai/leiku/561
After the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!
Once this is done, we will invoke this class in the new PHP file, and instantiate the class:
<?phpinclude_once "json.php";//Introduce class file $ARR1 = Array ("website" = "php Chinese web", "url" = "www.php.cn");//define array $obj = new JSON ( $arr 1); Instantiate echo "Parse main function:". $obj->mainarr (). " <br> ";//Parse main function echo" parse index array: ". $obj->indexarr ($arr 1)." <br> ";//Parse index array $arr2 = Array (" 123 "=" php Chinese "," 124 "=" www.php.cn ");//fixed to numeric index array echo" Parse array of numbers: ". $obj Numarr ($arr 2). " <br> ";//analytic array of numbers?>
Run the file and get the results as shown: