note 48101 added to function.str-replace
| From: | hermes at andycostell dot com | Date: | Sat, 11 Dec 2004 19:57:02 +0000 |
| Subject: | note 48101 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81698@lists.php.net to get a copy of this message | ||
A simple function to take out the double line breaks "%0D%0A" from a string made from text
being wrapped in a textarea and turn them into single line breaks.
<?php
function remove_extra_linebreaks($string) {
$new_string=urlencode ($string);
$new_string=ereg_replace("%0D", " ", $new_string);
$new_string=urldecode ($new_string);
return $new_string;
}
?>
I use it when taking text from a textarea with wrap="hard" that I'm emailing out on
the next page, for instance. Otherwise there's an extra empty line between each line in the
emailed text, which looks nasty!
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48101
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48101&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48101&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48101&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48101&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48101&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48101&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48101&report=yes
Search -- http://master.php.net/manage/user-notes.php