note 27988 rejected from function.html-entity-decode by nicos

From: Date: Sun, 29 Dec 2002 01:36:41 +0000
Subject: note 27988 rejected from function.html-entity-decode by nicos
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-41405@lists.php.net to get a copy of this message
The following code will NOT work as expected: $string = "&nbsp;&nbsp;&nbsp;foobar&nbsp;&nbsp;&nbsp;"; $string = html_entity_decode($string); echo "<pre>" . trim($string) . "</pre>"; Why? Because html_entity_decode replaces &nbsp; with 0xa0 and not 0x20 which is the one being removed with trim(). As a result of this, you must use the following code instead: echo "<pre>" . trim($string,"\xa0") . "</pre>";

« previous php.notes (#41405) next »