【问题标题】:php read txt file from 5th letter to 6th letterphp从第5个字母到第6个字母读取txt文件
【发布时间】:2014-03-25 22:02:45
【问题描述】:

我想读取 txt 文件中的字母,但只能读取第 5 到第 6 个字母(2 个字母)

<?  $myFile = "administrator/data.txt"; 
    $fh = fopen($myFile, 'r'); 
    $theData = fread($fh, 4); 
    fclose($fh); 
?>

此代码读取前4个数字,但我不知道如何选择第5到第6个字母的字母。

【问题讨论】:

    标签: php fread


    【解决方案1】:

    首先使用fseek 将文件指针前进到所需位置。

    ...
    fseek($fh, 5);
    $theData = fread($fh, 2);
    ...
    

    【讨论】:

      猜你喜欢
      • 2022-11-04
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-23
      • 2018-07-11
      • 2018-07-08
      • 1970-01-01
      相关资源
      最近更新 更多