One liner to parse a CSV file into an array by using str_getcsv.
$csv = array_map( 'str_getcsv', file( 'qryWebsite.csv' ) );
To build a database query that will import all the values into database at once:
$query =
"INSERT INTO tbl_name (a,b,c) VALUES " .
implode( ',', array_map( function( $params ) use ( &$values ) {
$values = array_merge( (array) $values, $params );
return '(' . implode( ',', array_fill( 0, count( $params ), '?' ) ) . ')';
}, $csv ) );
This will build a prepared statement with question mark placeholders, like:
INSERT INTO tbl_name (a,b,c) VALUES (?,?,?),(?,?,?),(?,?,?),(?,?,?)
, and variable $values will be one-dimensional array that holds values for the statement. One caveat here is that csv file should contain less than 65,536 entries ( maximum number of placeholders ).