note 107391 deleted from function.trim by hholzgra

From: Date: Thu, 02 Aug 2012 12:32:37 +0000
Subject: note 107391 deleted from function.trim by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189680@lists.php.net to get a copy of this message
Note Submitter: Eric de Ruiter ---- If you want to trim html whitespace (&nbsp; entities and <br /> tags) you can use this function. Input should be valid utf8. <?php function htmltrim($string) { $pattern = '(?:[ \t\n\r\x0B\x00\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}]|&nbsp;|<br\s*\/?>)+'; return preg_replace('/^' . $pattern . '|' . $pattern . '$/u', '', $string); } ?>

« previous php.notes (#189680) next »