note 104251 added to function.trim
| From: | gerjoo at gmail dot com | Date: | Fri, 03 Jun 2011 15:38:37 +0000 |
| Subject: | note 104251 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180222@lists.php.net to get a copy of this message | ||
On my application I had several users submit what to me appeared as "empty strings",
whereas in fact they were submitting the ­ character.
Trim, by default, does not strip this character (Though arguably it should). The following code
strips this character from your input:
<?php
// As the ­ character is invisible we'll simply use the ASCII numeric representation,
and decode via chr():
$string = trim($string, chr(173));
// If you wish to strip all occurences this will work:
$string = str_replace(chr(173), "", $string);
?>
Gerard
----
Server IP: 213.249.64.162
Probable Submitter: 83.87.181.228
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- https://master.php.net/note/edit/104251
Del: integrated -- https://master.php.net/note/delete/104251/integrated
Del: useless -- https://master.php.net/note/delete/104251/useless
Del: bad code -- https://master.php.net/note/delete/104251/bad+code
Del: spam -- https://master.php.net/note/delete/104251/spam
Del: non-english -- https://master.php.net/note/delete/104251/non-english
Del: in docs -- https://master.php.net/note/delete/104251/in+docs
Del: other reasons-- https://master.php.net/note/delete/104251
Reject -- https://master.php.net/note/reject/104251
Search -- https://master.php.net/manage/user-notes.php