I have a big txt file (40mb) that contains some strings, the file is like this:
AN,Aixas|AN,Aixirivall|AN,Aixovall|AN,Andorra la Vella|AN,Ansalonga|AN,Anyos|AN,Arans|
I have a key (two letters) and a value (the city), so i have a problem, when i try to split it in PHP with this function, and when i try to insert data in my database.
The function that i use in php is:
$file = explode("|", file_get_contents('city.txt'));
$city = explode(",", $file);
foreach ($city as $key => $value)
mysqli_query($mysqli, "INSERT INTO city(name_city, id_city) VALUES ('$key', '$value')");
An error occured:
[29-Apr-2016 14:33:09 Europe/Berlin] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes) in /home/mypath on line 6
I think that my file is more big to be processed, how i can parse and insert my data in my db ?