Answer the question
In order to leave comments, you need to log in
Wrote a universal csv parser in PHP How many queries should be split optimally?
Small volumes are parsed normally.
But with 4MB it's a long time.
<?php
$file_name="tools.csv";
$fp = fopen($file_name, 'r');
$head = fgetcsv($fp, 4096, ';', '"');
while($column = fgetcsv($fp, 4096, ';')){
$column = array_combine($head, $column);
$ww[]=$column;
}
$dd[] = $ww;
echo"<table><tr>";
for ($i = 0; $i <count($head); $i++) {
echo "<th>".$head[$i]."</th>";//Вывод заголовков полей
}
echo "</tr>";
foreach ($dd as $key){
echo"<tr>";
foreach ($key as $key2) {
for ($i = 0; $i <count($head); $i++) {
echo "<td>".$key2[$head[$i]]. "</td>"; //Вывод строк
}
echo"<tr>";
}
}
echo"</table>";
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question