Why does echoing the input from a php file that has been read only print on a single line? - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, June 4, 2021

Why does echoing the input from a php file that has been read only print on a single line?

First I am trying to store the parsed info from the file separated by the comma on each line into it's own object. So from the example text below each object would have two properties [some text, here] and [other text, there]

However, before I can even do that I need to access a single line. It seems that the code I am using will only output the data read in on a single line. I am sure it's something simple I am missing. Is there a way to retrieve each line individually in PHP?

$file = new SplFileObject("/test5.txt");

while(!$file->eof())
  {
    echo $file->fgets()."<br/>";
  }

$file = null;

text file being read output from code



source https://stackoverflow.com/questions/67826667/why-does-echoing-the-input-from-a-php-file-that-has-been-read-only-print-on-a-si

No comments:

Post a Comment