note 31556 added to function.trim
| From: | bishop at rack1 dot php dot net | Date: | Fri, 25 Apr 2003 19:47:10 +0000 |
| Subject: | note 31556 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47114@lists.php.net to get a copy of this message | ||
Non-breaking spaces can be troublesome with trim (as per an earlier comment):
// turn some HTML with non-breaking spaces into a "normal" string
$myHTML = " abc";
$converted = strtr($myHTML, array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES)));
// this WILL NOT work as expected
// $converted will still appear as " abc" in view source
// (but not in od -x)
$converted = trim($converted);
// are translated to 0x40, so use:
$converted = trim($converted, "\xA0");
// PS: Thanks to John for saving my sanity!
--
http://www.php.net/manual/en/function.trim.php
http://master.php.net/manage/user-notes.php?action=edit+31556
http://master.php.net/manage/user-notes.php?action=delete+31556
http://master.php.net/manage/user-notes.php?action=reject+31556