note 107391 added to function.trim

From: Date: Mon, 06 Feb 2012 14:20:25 +0000
Subject: note 107391 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-185870@lists.php.net to get a copy of this message
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); } ?> ---- Server IP: 213.249.64.162 Probable Submitter: 80.126.250.8 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/107391 Del: integrated -- https://master.php.net/note/delete/107391/integrated Del: useless -- https://master.php.net/note/delete/107391/useless Del: bad code -- https://master.php.net/note/delete/107391/bad+code Del: spam -- https://master.php.net/note/delete/107391/spam Del: non-english -- https://master.php.net/note/delete/107391/non-english Del: in docs -- https://master.php.net/note/delete/107391/in+docs Del: other reasons-- https://master.php.net/note/delete/107391 Reject -- https://master.php.net/note/reject/107391 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185870) next »