hey guys this is the script i've got... but i can't seem to get it right. ===================================== $line = file('/home/local/file.txt'); $line2 = explode("\n", $line); $i=0; while($i <= count($line2)) { $data = explode("|", $line[$i]); echo "$data[$i]\n"; $i++; } ===================================== it only print out id1 and fname for id2. can someone kindly assist me here.. thanks in advance. Earl ----- Original Message ----- From: "John W. Holmes" <holmes072000@charter.net> To: "'Earl'" <earl@caribsports.com>; "'PHP-DB'" <php-db@lists.php.net> Sent: Sunday, May 18, 2003 2:40 PM Subject: RE: external file content > > this may seem like a simple thing to do but i'm just a newbie to PHP. > > here goes. > > > > i've got and external life "/my/path/report.txt" > > the content of this file is arranged as > > > > id1|fname|lname|address|country|post_code > > id2|fname|lname|address|country|post_code > > id3|fname|lname|address|country|post_code > > id4|fname|lname|address|country|post_code > > id5|fname|lname|address|country|post_code > > id6|fname|lname|address|country|post_code > > id7|fname|lname|address|country|post_code > > > > i would like to be able to read through the file and extract each line > to > > be places in a table. > > Read the file with the file() function to get each line as an element in > an array. Loop through the array and explode each element by the | > character. You've then got each part of the file in it's own variable. > > www.php.net/file > www.php.net/explode > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php