Sometime you want to pass a large dataset into a mysql table using PHP.
Assembling one INSERT statement with multiple rows is much faster in MySQL than one INSERT statement per row. This sounds like you might be running into string-handling problems in PHP, if fact it is an algorithm problem. Basically, when working with large strings, you want to minimize unnecessary copying. In order to insert hundreds of rows at once, the fastest and most memory efficient way to build a large string is to take advantage of the implode() function and array assignment. Read Insert multiple rows via a PHP array into MYSQL