I want to make a foreach loop to display the has_arrived status in php.
when i tried with var_dump(has_arrived) it returned the output as false.but i want the output as,
i have decoded and stored the decoded values in the $json variable
Kindly help me to suggest the idea and help me to solve the issue
my php code:
<!DOCTYPE html>
<HTML>
<HEAD>
<META charset="utf-8">
<TITLE>Train Status Time Table</TITLE>
</HEAD>
<BODY>
<TABLE>
<TR><TH>Station<TH>Scheduled<TH>Actual<TH>Status/Delay
<?php
$json = '';
if(isset($_GET['trainnumber']) && (isset($_GET['doj']))) {
$url = 'http://api.railwayapi.com/live/train/'.$_GET['trainnumber'].'/doj/'.$_GET['doj'].'/apikey/jvtnb8382/';
$json = json_decode(file_get_contents($url), true);
foreach($json['route'] as $stop) {
echo ' <TR><TD>'.$stop['station'].'<TD>'.$stop['scharr'].'<TD>'.$stop['actarr'].'<TD>'.$stop['has_arrived'].'<TD>'.$stop['has_departed'].'<TD>'.$stop['latemin']."\n";
}
} else {
echo "Something went wrong, please notify to admin [
[email protected]]";
}
?>
</TABLE>
</BODY>
</HTML>