2012-04-23

CODE - php 逐行讀檔 sample


$filename = '/home/www/test.txt';
$handle = @fopen($filename, 'r');
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle); // fgets為每次讀取一列文字
        if ($buffer==null) {
            continue;
        }
        $mid = trim($buffer);
        ...
    }
}
error_log('all done.');
fclose($handle);



沒有留言:

張貼留言