Search code examples
phpsubstreol

substr() to EOL?


How can I grab the entire contents of a line? I have a suspicion substr() is not the answer.

Authors: Mr. Foo, Mr. Bar
Date: Jan 1, 1970
etc...

In my $file_text string I have something similar to above. I'm looking for something like this:

$author_line = substr($file_text, 0, EOL);

Solution

  • Getting the file contents with file() automatically cuts it up into lines for you, if it helps.

    Otherwise, try strstr($file_text,PHP_EOL,true)