RE: external file content

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

 



> 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


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

  Powered by Linux