RE: [PHP] read text file into mysql
| From: | Maxim Maletsky \(PHPBeginner.com\) | Date: | Thu, 25 Apr 2002 01:21:09 +0000 |
| Subject: | RE: [PHP] read text file into mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94492@lists.php.net to get a copy of this message | ||
Do this:
$contents = file($file);
foreach($contents as $line_num=>$line_data) {
$data = explode('|', $line_data);
// now data contains:
// [0] = aa
// [1] = bb
// [2] = cc
// nd so on
}
Sincerely,
Maxim Maletsky
Founder, Chief Developer
www.PHPBeginner.com // where PHP Begins
> -----Original Message-----
> From: Rodrigo Peres [mailto:rperes@mac.com]
> Sent: Thursday, April 25, 2002 2:14 AM
> To: PHP
> Subject: [PHP] read text file into mysql
>
> Hi list,
>
> I need to read a txt file and insert it lineas a record in mysql.
> My list in the format
> aa|bbbbb bbbb| cccccc |
> fffffff|hhdhdhdh|jsjjsjs
>
> in other words my separator is "|" and the lines have a return at the
end of
> each one.
>
> I'm new to PHP, so can anyone help me with and Idea???
>
> thank's in advance
>
> Rodrigo
> --
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php