I have a foreach
looping in a file's data, this loop generates some values that are entered in array
with array_push
, precise break those values entered in this array
to generate multiple INSERT INTO
because some INSERT
were over 2500 characters long.
Code:
$dados = array();
foreach ($arquivo->entrada as $xyz):
...
array_push($dados, $valores);
endforeach;
implode(', ', $dados);
print_r(array_chunk($dados, 2, true));
With this, I can break the values every 2 entries of array
for example.
But how could I do this to have a query with multiple INSERT INTO
?
I do not know how to do this by adding INSERT INTO 'tabela' VALUES
VALUE-OF-ARRAY ;
to each new split.
Example of data added to array
:
('2615509767','Challenge','','','Portuguese','','')
Example of data obtained with print_r
:
Array
(
[0] => Array
(
[0] => ('2615509767','Challenge','','','Portuguese','','')
[1] => ('2178947891','Name','','','Portuguese','','')
)
[1] => Array
(
[2] => ('1877844784','City','','','English','','')
)
)
Example code:
INSERT INTO 'tabela' VALUES ('2615509767','Challenge','','','Portuguese','',''), ('2178947891','Name','','','Portuguese','','');
INSERT INTO 'tabela' VALUES ('1877844784','City','','','English','','');
How could I do this in php?