I have a term insertion system via CSV files, eg:
09999999;José
08888888;Maria
I get this file moved to the server, and then I open that file to insert into the database. My problem is that I need to validate the insert, I can not insert repeating phones into the same file, and for this I use this code for this:
$valida1 = array_search($numero1, $validaNumeroLista);
if (empty($valida1) )
{
array_push($validaNumeroLista, $numero1);
}
After this I insert into the database, the problem is that the insertion time has increased a lot.
For example:
Before entering this validation, a file with up to 20 thousand lines would take around 5 to 7 seconds. Now, with 1 thousand lines it takes more than 2 minutes. Over 2 thousand lines is impossible to insert.
Do you have any tips on how to improve this performance?