Reading specific data from a .txt file into PHP

From: Date: Tue, 16 Jan 2001 14:58:25 +0000
Subject: Reading specific data from a .txt file into PHP
Groups: php.general 
Request: Send a blank email to php-general+get-34818@lists.php.net to get a copy of this message
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.

« previous php.general (#34818) next »