回覆列表
  • 1 # 使用者8140234220371

    $c = getLine("./a.txt", 10); // 讀取a.txt檔案第10行內容

    echo $c;

    /**

    * 獲取指定行內容

    *

    * @param $file 檔案路徑

    * @param $line 行數

    * @param $length 指定行返回內容長度

    */

    function getLine($file, $line, $length = 4096){

    $returnTxt = null; // 初始化返回

    $i = 1; // 行數

    $handle = @fopen($file, "r");

    if ($handle) {

    while (!feof($handle)) {

    $buffer = fgets($handle, $length);

    if($line == $i) $returnTxt = $buffer;

    $i++;

    }

    fclose($handle);

    }

    return $returnTxt;

    }

  • 中秋節和大豐收的關聯?
  • 蘋果6s的觸屏不靈敏怎麼回事?