NEWS: Total Picture Views: 140777 | Total Article Views: 143477 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Catch the Robots game with Becker Robots

How to read a JSON and work with it PHP/MySQL

Description:

In this example I will be showing you how to read a JSON file and work with it. 

Example: https://www.jmdev.ca/sheridan/example/4/

Code:

<?php

$content = file_get_contents('https://www.jmdev.ca/sheridan/api/picture/');
$array = json_decode($content, TRUE);

//** To read the array: **
//print_r($array);

echo "ID, Image Location, Uploaded Date and Image Size <br>";
for($i = 0; $i <= sizeof($array); $i++){
    echo $array[$i]['albumId'] . ": [" . $array[$i]['imageLocation'] . "] [" . $array[$i]['uploadedDate'] . "] [" . $array[$i]['imageSize'] . "]<br>";
}
Attachments: None

Tags: SizeOf JSON For loop Print_r

Total Views: 2215

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 01/11/15


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.