note 31559 deleted from function.trim by hholzgra

From: Date: Thu, 02 Aug 2012 12:19:44 +0000
Subject: note 31559 deleted from function.trim by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189628@lists.php.net to get a copy of this message
Note Submitter: bishop ---- [Editor: I botched my last note; please delete and use this one] 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 0xA0, so use: $converted = trim($converted, "\xA0"); // PS: Thanks to John for saving my sanity!

« previous php.notes (#189628) next »