note 44320 deleted from function.str-replace by tomsommer

From: Date: Tue, 20 Jul 2004 23:46:47 +0000
Subject: note 44320 deleted from function.str-replace by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73771@lists.php.net to get a copy of this message
Note Submitter: jeroen@telartis.nl ---- another way to remove accents from text in PHP 5: <? function accents($text) { $s = 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿÆæ'; $r = 'AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'; return str_replace(str_split($s), array_merge(str_split($r), array('AE', 'ae')), $text); } ?> and without str_split function: <? function accents($text) { $p = '/.{1,1}/'; preg_match_all($p, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿÆæ', $s); preg_match_all($p, 'AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy', $r); return str_replace($s[0], array_merge($r[0], array('AE', 'ae')), $text); } ?>

« previous php.notes (#73771) next »