Re: external file content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
*/


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux