note 22002 added to function.trim
| From: | daggillies at yahoo dot com | Date: | Mon, 03 Jun 2002 15:57:57 +0000 |
| Subject: | note 22002 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31383@lists.php.net to get a copy of this message | ||
NOTE:
All the above examples using ereg_replace with an escape code of \v are BROKEN! \v is NOT an escape
code in PHP. Using a regexp of \v e.g.
$str=ereg_replace("[\r\t\n\v]","",$str);
will remove any instances of the letter 'v' from your string. So 'Activity'
becomes 'Actiity'. Probably not what you want.
Here is a small function I use to strip whitespace from the end of strings and squash repeated
whitespace down to a single space in the middle of strings:
function wsstrip(&$str)
{
$str=ereg_replace (' +', ' ', trim($str));
$str=ereg_replace("[\r\t\n]","",$str);
}
David Gillies
San Jose
Costa Rica
--
http://www.php.net/manual/en/function.trim.php
http://master.php.net/manage/user-notes.php?action=edit+22002
http://master.php.net/manage/user-notes.php?action=delete+22002
http://master.php.net/manage/user-notes.php?action=reject+22002