Hi ,i have posted my code here.
Livetrainstatus.php code:
[code=php]<!DOCTYPE html>
<HTML>
<HEAD>
</head>
<body>
<?php
$json = ”;
if(isset($_GET[‘trainnumber’]) && (isset($_GET[‘doj’]))) //passing the train number and doj from home page to here
{
$url = ‘http://api.railwayapi.com/live/train/’.$_GET[‘trainnumber’].’/doj/’.$_GET[‘doj’].’/apikey/jvtnb8382/’; //api url
$json = json_decode(file_get_contents($url), true);
echo “<center>Station<center><center>Scheduled<center>center>Actual<center><center>Status/Delay”;
foreach($json[‘route’] as $stop) {
($stop[‘has_arrived’] === true) ? $stop[‘has_arrived’] = “Arrived” : $stop[‘has_arrived’] = “Still not here yet!”;
echo ‘ <center>’.$stop[‘station’].'<center>’.$stop[‘scharr’].'<center>’.$stop[‘actarr’].'<center>’.$stop[‘has_arrived’].”n”;
}
} else {
echo “Something went wrong, please notify to admin [[email protected]]”;
}
?>
</BODY>
</HTML>
output:
[QUOTE]
here it will produce the station,scheduled arrival,actual arrival,arrived status.
Json Response:
[QUOTE]
{
“response_code”: 200,
“stations”: [
{
“lng”: 83.3731675,
“lat”: 26.7605545,
“code”: “GKP”,
“state”: “Uttar Pradesh”,
“fullname”: “Gorakhpur Jn”
},
{
“lng”: 83.5842775,
“lat”: 26.6492695,
“code”: “CC”,
“state”: “Uttar Pradesh”,
“fullname”: “Chauri Chaura”
},
{
“lng”: 83.2142269,
“lat”: 26.758544,
“code”: “SWA”,
“state”: “Uttar Pradesh”,
“fullname”: “Sahjanwa”
},
{
“lng”: 83.3742644,
“lat”: 26.7401226,
“code”: “DDP”,
“state”: “Uttar Pradesh”,
“fullname”: “Daudpur”
}
]
}
This is the url format for getting the above api response.
[QUOTE]
[url]http://api.railwayapi.com/code_to_name/code/gkp/apikey/12345/
i want to pass all the station name from livetrainstatus.php to this url and make the output as
[QUOTE]
fullname (code) ,scheduled arrival,actual arrival,arrived status
here what i want is the livetrainstatus.php defaults print the station code only like GKP,but i want it should be Gorakhpur(GKP).
can anyone suggest the code or logic.
so that it will help me a lot.
Thank u so much for reading this.