note 104251 deleted from function.trim by peehaa
| From: | peehaa@php.net | Date: | Tue, 21 Mar 2017 08:41:48 +0000 |
| Subject: | note 104251 deleted from function.trim by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208927@lists.php.net to get a copy of this message | ||
Note Submitter: gerjoo at gmail dot com
----
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