Re: external file content
| From: | Jason Wong | Date: | Wed, 21 May 2003 17:49:58 +0000 |
| Subject: | Re: external file content | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27947@lists.php.net to get a copy of this message | ||
On Thursday 22 May 2003 01:21, Earl wrote:
> 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.
*** Untested ***
$line = file('/home/local/file.txt');
foreach ($line as $l => $val) {
$bits = explode('|', $val);
foreach ($bits as $bit) {
echo "$bit\n";
}
}
It may be slightly easier to use fgetcsv(), just follow example in manual.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
If someone says he will do something "without fail", he won't.
*/