Array Help - PHP XML



My code (PHP):



<html>
<head>
<link href='http://ift.tt/OIiP2w' rel='stylesheet' type='text/css'>
<style>
body {
background-color: rgba(255, 255, 255, 0.3);
font-family: 'Open Sans', sans-serif;
text-align:center;
}
</style>
</head>
<?php
$url = 'http://ift.tt/1H1P10S';

$parser = new XMLReader;
$parser->open($url);

while ($parser->read()) {
if ($parser->nodeType === XMLReader::ELEMENT) {

while ($parser->name === 'pod' && $parser->getAttribute('title') !== 'Result')
$parser->next('pod'); // jump to the next pod node

if ($parser->name === 'plaintext') {
$str = $parser->readString();
$parser->close();
break;
}
}
}

$lines = explode("\n", $str);
$result = array();

foreach ($lines as $line) {
$fields = explode(' | ', $line);
$flight = array_shift($fields);
$flight = $flight . "<hr>"; //DELETE IF DOESN'T WORK

if ($flight === '')
$cols = $fields;
elseif (isset($fields[1])) {
$result[$flight][$cols[0]] = $fields[0];
$result[$flight][$cols[1]] = $fields[1];
}
}

foreach($result as $key=>$value)
{
echo $key;
foreach($value as $value1){

echo $value1;
echo " &nbsp;";
}
}






Basically uses Wolfram Alpha API to get planes nearby, then display it. Issue how can I remove the plane direction and the phrase 'Slant distance'

Sample output below:




slant distance ENY flight 3278
14 miles NNW Frontier Airlines flight 72
44 miles N American Airlines flight 1241
15 miles NW American Airlines flight 396
23 miles W Atlantic Southeast Airlines flight 6104
49 miles SSE




So, again, I just need 'Slant Distance' & n miles direction remove.



Thank you


No comments:

Post a Comment