Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Fetching Weather in php

$
0
0

Hello PHP Freaks Forums,

 

I am trying to construct a web app to fetch weather off "http://www.flightstats.com", and look up the airport code and display weather for that airport code in that location.  I have some code i started writting that has few errors i need help fixing.  The code fetches weather off of the flightstats.com, but i need to figure out how i could make a drop down box or form that a user can type a airport code and fetch the weather from flight stats or if you have better website that works better please feel free to suggest it.  Thanks.

 

There is error in line three.

<?php
$airport_code = $_GET["airport"];;
    function get_string_between($string, $start, $end)
    {
        $string = " ".$string;
        $ini = strpos($string,$start);
        if ($ini == 0)
            return "";
        $ini += strlen($start);
        $len = strpos($string,$end,$ini) - $ini;
        return substr($string,$ini,$len);
    }
    $data = file_get_contents("http://www.flightstats.com/go/Airport/weather.do?airportCode=".$airport_code."");

    $weatherdiv = get_string_between($data, '<table width="237" class="contentTable">', '</table>');
    $weathertext = strip_tags($weatherdiv);
    ?>
    
    
<table width="237" class="contentTable">
<?php echo $weathertext; ?>
</table>
 

 

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles