Welcome folks today in this blog post we will be reading and parsing json file data from a rest api in browser
using php 7
. All the full source code of the application is shown below.
Get Started
In order to get started you need to make an index.php
file and copy paste the following code
index.php
<?php
$jsonfile = file_get_contents("http://domain.com/jsonfile.json");
$jsonIterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($jsonfile, TRUE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($jsonIterator as $key => $value) {
if(is_array($value)) {
echo "$key:\n";
}
else {
echo "$key => $value\n";
}
}
?>
Here you can change the password in the above php
script