Re: Line by line

From: Date: Fri, 28 Sep 2001 16:26:27 +0000
Subject: Re: Line by line
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12824@lists.php.net to get a copy of this message
An easy way to access a file line by line for processing: $lines = file("/file/name/here/") or die ("Unable to open file"); foreach ($lines as $line) { ... processing commands here ... } You could even add a line like: if (sizeof($lines) > 0) { print "Data exists"; } You can use that as opposed to checking to see if the file exists because the "or die" statement will alert youto any possible problems (file doesn't exist, permissions are wrong, etc). Mike Frazer "Devon" <martin@enet21.com.au> wrote in message news:20010928004720.5771.qmail@pb1.pair.com... > Below is my source that sipply opens a file > > <?php > $fp = fopen ("http://localhost/Install.txt", > "r"); > if ($fp) > { print"The file exists!"; } > else > { print"The file does not exist"; } > ?> > > I Need to be able to a. print the file out b. The file must be printed out > line by line c. Write each seperate line to a mysql data base in different > tables. > > Any help would be awsome > Cheers > >

« previous php.db (#12824) next »