[ACCEPTED]-Select from position to end of line in string-string
Accepted answer
It should be :
substr($string, $pos, ( strpos($string, PHP_EOL, $pos) ) - $pos);
0
You can try the PHP_EOL
constant:
substr($string, $pos, strpos($string, PHP_EOL, $pos));
It contains the 2 end-of-line character sequence of the OS 1 the script is running.
Pass the string through a function which 4 replaces \r\n or \r with \n first. It's 3 worth doing as a matter of course, unless 2 you actually want to preserve platform specific 1 line endings.
FWIW Mac's use \n now anyway.
If you need to process each individual line 4 in the string you can always split the string 3 into a array. You can do this using preg_split() in 2 a way that will identify more than systems 1 end of line character.
$lines = preg_split("/\r\n|\n|\r/", $string);
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.