note 84385 added to function.preg-replace

From: Date: Fri, 11 Jul 2008 11:59:06 +0000
Subject: note 84385 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-141401@lists.php.net to get a copy of this message
Take care when you try to strip whitespaces out of an UTF-8 text. Using something like: <?php $text = preg_replace( "{\s+}", ' ', $text ); ?> brokes in my case the letter à which is hex c3a0. But a0 is a whitespace. So use <?php $text = preg_replace( "{[ \t]+}", ' ', $text ); ?> to strip all spaces and tabs, or better, use a multibyte function like mb_ereg_replace. ---- Server IP: 217.160.72.57 Probable Submitter: 217.91.122.70 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/84385 Del: integrated -- https://master.php.net/note/delete/84385/integrated Del: useless -- https://master.php.net/note/delete/84385/useless Del: bad code -- https://master.php.net/note/delete/84385/bad+code Del: spam -- https://master.php.net/note/delete/84385/spam Del: non-english -- https://master.php.net/note/delete/84385/non-english Del: in docs -- https://master.php.net/note/delete/84385/in+docs Del: other reasons-- https://master.php.net/note/delete/84385 Reject -- https://master.php.net/note/reject/84385 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141401) next »