fopen not displaying contents

前端 未结 1 804
[愿得一人]
[愿得一人] 2021-01-29 05:53

Not sure why my im getting a blank page ? There is data in the .txt and no errors in the php ?



        
相关标签:
1条回答
  • 2021-01-29 06:42

    Every time you are echo the last line.

    And every $aLineOfCells is an array.You need to take it out.

    <?php
    $fp = fopen("products.txt", "r");
    flock($fp, LOCK_SH);
    $headings = fgetcsv($fp, 0, "\t");
    
    $aline = '';
    while ($aLineOfCells = fgetcsv($fp, 0, "\t")) {
      $records[] = $aLineOfCells[0];
      $aline = $aline . $aLineOfCells[0] . "\n";
    }
    
    flock($fp, LOCK_UN);
    fclose($fp);
    echo $aline;
    ?>
    
    0 讨论(0)
提交回复
热议问题