note 45914 added to function.ltrim
| From: | jakob at grimstveit dot no | Date: | Thu, 23 Sep 2004 11:51:17 +0000 |
| Subject: | note 45914 added to function.ltrim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77240@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.ltrim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45914
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45914&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45914&report=yes
Search -- http://master.php.net/manage/user-notes.php