RE: [PHP] extracting data from text file

From: Date: Mon, 01 Jul 2002 21:53:38 +0000
Subject: RE: [PHP] extracting data from text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-104788@lists.php.net to get a copy of this message
Here's one way assign each line: <?php $file_loc = "D:\\web\\bev\\file.txt"; $whattoread = fopen($file_loc, "r"); $country = fgets($whattoread, 4096); $state = fgets($whattoread, 4096); $city = fgets($whattoread, 4096); $company = fgets($whattoread, 4096); $division = fgets($whattoread, 4096); $url = fgets($whattoread, 4096); $email = fgets($whattoread, 4096); echo "country is $country<br>"; echo "state is $state<br>"; echo "city is $city<br>"; echo "comapny is $company<br>"; echo "division is $division<br>"; echo "url is $url<br>"; echo "email is $email<br>"; fclose($whattoread); ?> Bev -----Original Message----- From: rdkurth@starband.net [mailto:rdkurth@starband.net] Sent: Monday, July 01, 2002 5:17 PM To: php-general Subject: [PHP] extracting data from text file Hello , I have a text file that looks like this. each entry is on a different line I need to pull the data out of it and put each line of data into its own variable US State City Company Name Section 2 www.domain.com admin@www.domain.com I have trend this but it does not work properly $fp = @fopen(file.txt,"r"); $line = explode("\n",$fp); $valueC = "$line[0]"; $valueST = "$line[1]"; @fclose($fp); -- Best regards, rdkurth mailto:rdkurth@starband.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#104788) next »