note 45914 deleted from function.ltrim by aidan
| From: | aidan@php.net | Date: | Fri, 24 Sep 2004 01:31:11 +0000 |
| Subject: | note 45914 deleted from function.ltrim by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77286@lists.php.net to get a copy of this message | ||
Note Submitter: jakob at grimstveit dot no
----
To ltrim() all lines in a string ("foo\n bar\n baz" ->
"foo\nbar\nbaz\n"), you can probably do something like the following:
(PHP < 5)
<?php
while(substr_count($text, "\n ") > 0) {
$text = str_replace("\n ", "\n", $text);
}
?>
(PHP 5)
<?php
$replacements = -1;
while($replacements != 0)
$text = str_replace("\n ", "\n", $text, $replacements);
}
?>