Let's write this code for your friends, let's go here.

xiaoxiao2021-03-18  194

/ ***************

Data file B.TXT format

1-1 1-2

2-1 2-2

3-1 3-2

*****************

Export data a.sql format

INSERT INTO XXX (`a`,` b`) Values ​​('1-1', '1-2');

INSERT INTO XXX (`a`,` b`) VALUES ('2-1', '2-2');

INSERT INTO XXX (`a`,` b`) VALUES ('3-1', '3-2');

**************** /

$ INPUT = 'b.txt'; # data file

$ output = 'a.sql'; # export data

$ special = array ("", "");

$ key_word = array ('', '', '', '');

$ SQL_PRE = 'INSERT INTO XXX (`a`,` b`) Values';

##############################

$ fp = file ($ INPUT);

$ I = 0;

Foreach ($ FP AS $ Key => $ VAL) {

IF (REPLACE ($ fp [$ key])! = ') {

$ content. = $ sql_pre. "(". Replace ($ FP [$ Key]). "); / r / n";

$ i ;

}

}

IF (Write ($ OTPUT, $ Content))

Echo ('