[SOLVED] More help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Simon Angell
Forum Commoner
Posts: 45
Joined: Fri Jan 24, 2003 12:14 am

[SOLVED] More help needed

Post by Simon Angell »

Hi all.
sorry for the title, just not sure what to call the function help i need, lol

Anyways.
I Have got a script that grabs data and displays it, the script works fine except for when the $grab_end part is different to the defined value.

Code: Select all

<?php
$query = ($_SERVER['QUERY_STRING']);
$length = "260";
$grab_start = "METAR $query";
$grab_end = "TAF    TAF $query";
$xurl =  "http://www.airservices.gov.au/brief/html.asp?/cgi-bin/avreq?area=21";
$read = file_get_contents($xurl);

 
$grab = eregi("$grab_start(.*)$grab_end", $read, $metgrab);

$metgrab[1] = str_replace("TAF    TAF AMD", "TAF    TAF $query", $metgrab[1]); 


trim($metgrab[1]);
  
$long = strlen($metgrab[1]);
 
if ($long < $length) {
echo "<pre>$query $metgrab[1]</pre>";
}
else { echo "<pre>$query $metgrab[1]</pre>"; }
 if ($_SERVER['QUERY_STRING'] == false)  {
echo "<center>No METAR station code has been selected, Please press back in your browser."; }
?>
Now either the part i want it to end is TAF TAF or TAF TAF AMD

Now the script works fine if the $grab_end that is defined is the one in use. ie. using the url http://www.canberra-wx.com/metgrab.php?YSCB ...

The script reads the query string, parses the document ($xurl) for the Match at $grab_start and $grab_end and then displays the info i want.
YSCB 130630Z 33008KT 9999 FEW030 09/04 Q1021 RMK
RF00.0/000.0 USE TAF FOR ARRIVALS AFTER 0800Z NOSIG
how ever using the url http://www.canberra-wx.com/metgrab.php?YGLB

display nothing because in this case the part i need it to end is TAF TAF AMD and the $grab_end is set for TAF TAF.

As you can see i tried a work around with the str_replace but this fails.

any help on getting $grab_end to use either TAF TAF AMD and TAF TAF or any other fix for the problem would be great.

thx in advanced![/b]
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

The cgi has other variables besides area. Maybe they will help?

http://www.airservices.gov.au/brief/htm ... &s3=0&s4=0

100 Posts!
Simon Angell
Forum Commoner
Posts: 45
Joined: Fri Jan 24, 2003 12:14 am

Post by Simon Angell »

ahhh, never knew that site did that.... will play around with it some more now, cheers!
Simon Angell
Forum Commoner
Posts: 45
Joined: Fri Jan 24, 2003 12:14 am

Post by Simon Angell »

Fantastic... Did what i need, and then some (another feature i was going to add later) - and all due using a diff URL
Post Reply