Category: JSON

  • Convert JSON Array to PHP Array

    To convert a JSON array into a PHP array, use the following script: <?php $json = file_get_contents(‘json/yourscript.json’); // Get the JSON data $phpObj = json_decode($json,true); // Convert to PHP Object print_r($phpObj); // Convert to PHP Array ?> file_get_contents(‘json/yourscript.json’); Allows you to get the JSON data easily. json_decode($json,true); Is a PHP function that converts your JSON…

  • Finding nested items in JSON object or associative array using PHP

    I had this problem recently when I used made a call to Yahoo Finance’s Stock quotes API for my Chinese website about US Stocks. Yahoo’s API returns the stock data in JSON form, but you can choose to handle it as a php object or associative array. First, this post by Michael Nitschinger really helped…