j007ha Posted August 27, 2008 Share Posted August 27, 2008 i have a text file which is i going to store all of the data in the text file into a database. For example: |AR_CUSTNO |AR_CUSTNME |AR_ADD1 |AR_ADD2 |AR_ADD3 |AR_ADD4 |AR_TELNO in the text file all of the column is seperate by a " | " sign...so how i using preg_replace to get rid of the " | " sign ? so i can insert all the data into the database table. thx for any reply^^ Link to comment https://forums.phpfreaks.com/topic/121510-preg_replace/ Share on other sites More sharing options...
True`Logic Posted August 27, 2008 Share Posted August 27, 2008 hehe I used to do this before I used mysql.. try.. <?php //--MYSQL_CONNECT ETC GOES HERE--// $ft = fread(fopen("FILENAME.txt", "r"), filesize("FILENAME.txt")); $fr = explode(" ", $ft); $i = 0; foreach($fr as $value) { $fa = explode("|", $value); @mysql_query("insert into TABLE(CustNum, CustName, AR_ADD1, AR_ADD2, AR_ADD3, AR_ADD5, AR_TELNO) values('$fa[0]', '$fa[1]', '$fa[2]', '$fa[3]', '$fa[4]', '$fa[5]', '$fa[6]')"); } ?> that's how I did it anyway.. If I remember right.. Link to comment https://forums.phpfreaks.com/topic/121510-preg_replace/#findComment-626637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.