Re: How to insert to DB from txt??? Please help
| From: | Jason Wong | Date: | Fri, 04 Jan 2002 16:46:18 +0000 |
| Subject: | Re: How to insert to DB from txt??? Please help | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15400@lists.php.net to get a copy of this message | ||
On Saturday 05 January 2002 00:44, Kelvin wrote:
> Hi everyone,
>
> I have a txt file which is contained the following:
>
> xxxx,aaa,ccc,ddd
> xxxx,aaa,ccc,ddd
> .....etc.
>
> Now, I need to read the data from that file and than insert it into the
> table.
>
> ----insert into Table
> ("name","pass","phone","somethingelse")
>
> Could someone help me out here, How to write the code?
> I know how to read from a txt file, but I don't know how to separate the
> data determine by ","
Use explode(). For example:
$line = "xxxx,aaa,ccc,ddd";
$bits = explode(",", $line);
Would result in:
$bits[0] = "xxxx"
$bits[1] = "aaa"
$bits[2] = "ccc" etc.
hth
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
Love conquers all things; let us too surrender to love.
-- Publius Vergilius Maro (Virgil)
*/