Gets the start line number $ start, $ limit span of the contents of the file

// 获取指定开始行数$page,跨度$step的文件内容
function getLine($file_name, $start, $limit)
{
    $f = new SplFileObject($file_name, 'r');
    $f->seek($start);
    $ret = "";
    for ($i = 0; $i < $limit; $i++) {
        try {
            $ret .= $f->getCurrentLine();
            $f->next();
        } catch (Exception $e) {
            break;
        }
    }
    return $ret;
}

Guess you like

Origin www.cnblogs.com/phonecom/p/10986473.html