You basically have two options.

1) You can use readfile() to open the file into an array then $line =
explode(':', $file) in a for loop to split the values from each line.
search for 'readfile' and 'explode' on php.net

2) You can fopen() the file and use $data = fgetcsv($fp, 1000, ':') then
your desired information will be at $data[0];
search for 'fopen' and 'fgetcsv' on php.net

Either way is equally valid.  The only differences is the fopen method makes
it alot easier to write data back to the delimited file if that's something
you need to do.

-Kevin


----- Original Message -----
From: "Miguel Brás" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 06, 2003 11:40 AM
Subject: [PHP] Read file and get what i want


> Hello gents,
>
> I made a script to open a file on a server and write his content to a temp
> file on my server.
>
> A part of the temp file is below:
>
> *******temp file**********
>
> !GENERAL
> VERSION = 1
> RELOAD = 1
> UPDATE = 20030206181916
> CONNECTED CLIENTS = 178
> CONNECTED SERVERS = 12
> !CLIENTS
> AHS5577:134723:RUBÉN FALCÓN
>
LEBG:PILOT::42.226630:-1.795440:35248:423:T/B763/F:410:LEBL:35000:LEST:IVANB
> E:1:1:4001:0:40:0:I:1715:1715:1:30:4:30:NONE:NONE
> :LEBL - LOBAR 1C - UN725 - LOMDA 1G - LEST:::::::20030206181830
> OBS::FRANCIS
>
BALLION:ATC:199.999:44.791670:0.541670:0:0::::::IVANDE:9:1:0:0:100::::::::::
> ::::::::20030206181821
> I-JEST:127128:ROBERTO PIETRAFESA
>
LIBG:PILOT::41.791590:12.244720:17:0:T/B737/T:300:LIRF:15000:LICD:IVANBE:1:1
> :0:0:40:0:I:1930:1930:1:0:4:30:NONE:CHARTS ON BOARD
>
:LIRF-ROTUN-CORAD-GIANO-PAL-PAL14-LONDI-MABOX-RATOK-MADIR-ASDAX-DEDUK-LPD-LI
> CD:::::::20030206181816
> ELY0001:127632:OMRI ATAR
>
LLBG:PILOT::31.996330:34.892110:153:0:T/B772/F:486:LLBG:FL380:KJFK:IVANGR2:1
> :1:1200:0:40:0:I:1000:1100:1:30:4:30:NONE:NONE
> :DENA1E -> SUVAS KAROL  APLON MAROS DASNI TOMBI AYT KUMRU ELMAS EKSEN KFK
> HANKO GAYEM WRN BALIK ARGES BUKEL PELUR DEMUN REBLA KARIL PITOK SLC BABUS
> BNO BODAL VLM ILNEK DONAD VARIK PEROX SODRO TABAT TAMEB ROBEL KEMAD HMM
> RELBI RKN TENLI FLEVO:::::::20030206181756
> DLH001:138912:MANUEL KAUFMANN
>
EDDT:PILOT::52.556900:13.294230:133:28::::::IVANDE2:1:1:1200:0:40:::::::::::
> :::::::20030206181755
>
> *********End of temp file***********
>
> Now the tricky part...
>
> Each part is separated by a :  Example AHS5577:134723:RUBÉN FALCÓN
> LEBG:PILOT::
> first part is callsign, then is the id, then the name, type and so on and
on
> (some parts has no data >>::<<)
>
> Now, how do I get the first part (callsign) of each line so i can make
> something like:
> if ($first_part ==TAP){
> echo "TAP is online";
> } else {
> echo "TAP isn't online";
> }
>
> Was I clear enough?
>
> Anyone has an ideia for this?
> Miguel
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to