Answer the question
In order to leave comments, you need to log in
How to read the first line of a large CSV file?
if (($handle = fopen($filename, 'r')) !== FALSE) {
$rowNumber = 0;
$output = array();
while (($row = fgetcsv($handle, 0, $delimiter)) !== FALSE) {
$num = count($row);
for ($i = 0; $i < $num; $i++) {
$output[$rowNumber][$i] = $row[$i];
}
$rowNumber++;
}
}
Answer the question
In order to leave comments, you need to log in
private function part($path, $offset, $rows) {
$buffer = array();
$buffer['content'] = '';
//$buffer['pointer'] = array();
$handle = fopen($path, "r");
fseek($handle, $offset);
if( $handle ) {
for( $i = 0; $i < $rows; $i++ ) {
$buffer['content'] .= fgets($handle);
//$buffer['pointer'] = mb_strlen($buffer['content']);
}
}
fclose($handle);
return($buffer);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question