RE: Reading specific data from a .txt file into PHP
| From: | Snorkel) | Date: | Tue, 16 Jan 2001 15:24:11 +0000 |
| Subject: | RE: Reading specific data from a .txt file into PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-34826@lists.php.net to get a copy of this message | ||
Sounds like a great database application, actually.
John Parker
> -----Original Message-----
> From: James Holloway [SMTP:james@towntalk.co.uk]
> Sent: Tuesday, January 16, 2001 8:58 AM
> To: php-general@lists.php.net
> Subject: Reading specific data from a .txt file into PHP
>
> Hi all,
>
> I'm attempting to write a weather script, which will display weather
> conditions for areas in the UK.
>
> I have the data I need, which is stored in a file on another server. The
> data comes in the format:
>
> 2001/01/16 13:50
> OOOO SCT010 BKNDPIP WYXWE Q1012
>
> 2001/01/16 13:46
> CYGL 161346Z 34004KT 15SM -SN BKN011 BKN030 RMK SF6SC1
>
> Where the first four characters below the dates are 4 letter codes for
> cities (the script will be using metar(aviation) readings) and the rest is
> the actual weather information.
>
> The trouble is, that there are about 3000 cities in the text file. I'm
> assuming that I fill use fopen(); and fread(); to open and read the files,
> but does anyone know of a way of singling out one line (say:
>
> CYGL 161346Z 34004KT 15SM -SN BKN011 BKN030 RMK SF6SC1
>
> ) from the whole text file? Like if a variable, $city = CYGL, is it
> possible to then go to that one line in the text file and read all the
> information from just one line? I'm pretty confident I could then split
> the
> information up into readable variable using the split(); function :)
>
> Thanks in advance for any help you might be able to give,
>
> James.
>
>