In PHP 5.3 there is a nice function that seems to do what I want:
strstr(input,"\n",true)
Unfortunately, the server runs PHP 5.2.17 and the optional third parameter of strstr
is not available. Is there a way to achieve this in previous versions in one line?
It's late but you could use explode.
Many times string manipulation will face vars that start with a blank line, so don't forget to evaluate if you really want consider white lines at first and end of string, or trim it. Also, to avoid OS mistakes, use PHP_EOL used to find the newline character in a cross-platform-compatible way (When do I use the PHP constant "PHP_EOL"?).
echo str_replace(strstr($input, '\n'),'',$input);
try this:
or something thereabouts would do the trick. Ugly, but workable.
try