note 84385 deleted from function.preg-replace by crell

From: Date: Fri, 01 Jul 2022 19:47:07 +0000
Subject: note 84385 deleted from function.preg-replace by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218855@lists.php.net to get a copy of this message
Note Submitter: David ---- 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.

« previous php.notes (#218855) next »