Code: Select all
Broken Bow, Broken Bow Municipal Airport, NE, United States (KBBW) 41-26N 099-39W
Jan 11, 2005 - 10:53 PM EST / 2005.01.12 0353 UTC
Wind: from the SSE (160 degrees) at 8 MPH (7 KT):0
Visibility: 2 1/2 mile(s):0
Sky conditions: overcast
Weather: mist
Temperature: 17.1 F (-8.3 C)
Windchill: 6 F (-14 C):1
Dew Point: 16.0 F (-8.9 C)
Relative Humidity: 95%
Pressure (altimeter): 29.59 in. Hg (1002 hPa)
ob: KBBW 120353Z AUTO 16007KT 2 1/2SM BR OVC002 M08/M09 A2959 RMK AO2 SLP057 T10831089
cycle: 4Code: Select all
$weatherdata = file_get_contents('ftp://weather.noaa.gov/data/observations/metar/decoded/KBBW.txt');Warning: file_get_contents(ftp://weather.noaa.gov/data/observation ... d/KBBW.txt): failed to open stream: FTP server reports 550 /data/observations/metar/decoded/KBBW.txt: not a plain file. in /home/grintfar/public_html/weather.php on line 28
So how can I get PHP to store the contents of the remote file into a variable? I am new to PHP and don't know anything about it so please speak in simple terms.
Then, after I get the contents in a variable, how can I remove the carriage returns from the text so that it is all on one line? That will help me in using the variable in JavaScript. Also, JavaScript does not like some of the characters that are in the text, such as parenthesis and slashes. Is there anyway I can remove them or place escape characters next to them with PHP before I export the contents of the variable to JavaScript? I will then use JavaScript to parse the data because I know JavaScript a lot better than I know PHP. Thanks.
Louie