I have this:
$text = '
hello world
hello
';
How do I remove
only if it is on its own line? So with above example, the second
should be removed. Results should be:
$text = '
hello world
hello
';
What I've tried so far
Via str_replace()
, I can:
$text = str_replace(' ', '', $text);
But that will remove all instances of
, not only when it's on its own line.