PHP/Network/stream get line
Версия от 10:37, 26 мая 2010; (обсуждение)
Counting records in a file with stream_get_line()
<?php
$records = 0;
$record_separator = "--end--";
if ($fh = fopen("database.txt","r")) {
$done = false;
while (! $done) {
$s = stream_get_line($fh, 65536, $record_separator);
if (feof($fh)) {
$done = true;
} else {
$records++;
}
}
}
print $records;
?>