To get the details with regards to "ID", I have prepared the following PHP with json array inside it. It is working perfectly.
<?php
$json = '{"records":
[
{"Name":"Jhon", "Age":"45", "id":"101"},
{"Name":"Bhil", "Age":"42", "id":"102"},
{"Name":"Tone", "Age":"41", "id":"103"},
]
}';
$myjson = json_decode($json, true);
foreach ( $myjson['records'] as $row ) {
if ($row['id'] =='216') {
echo 'Details of login id: '. $row['id']. '<br/>';
foreach ( $row as $field => $value ) { // loop the fields
// do the work here
}
}
}
?>
Now for one of my project, i have to crete arround 750 Ids with various vaules. Putting all these inside php file may slow down the page loading.
Hence, I have craeted json file(remote): xyz.com/dir/jsondata.json
Kindly guide me, how to incopporate the above json file in the php code.
file_get_contents()should work fine for this.