note 65192 added to function.preg-replace
| From: | p dot leblanc at caplaser dot fr | Date: | Wed, 26 Apr 2006 14:52:08 +0000 |
| Subject: | note 65192 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109748@lists.php.net to get a copy of this message | ||
<?php
/*
A simple way to use preg_replace() :
I have an array of french words, with accents. I want to create a similar array of these words
without accents.
*/
$words_w_accents = array ('déjà ', 'cafétéria', 'âtre',
'écrêmé', 'émoi', 'écho', 'hôte');
$search = array
('/é/','/è/','/ê/','/â/','/à /','/ô/');
$replace = array
('e','e','e','a','a','o');
for ($i=0; $i<count($words_w_accents); $i++){
$words_no_accents[$i][0] = preg_replace($search, $replace, $words_w_accents[$i]); // --- without
accents ---
}
/* Now the new array would be as follows :
$words_no_accents= array ('deja', 'cafeteria', 'atre',
'ecreme', 'emoi', 'echo', 'hote');
*/
?>
----
Server IP: 195.221.21.36
Probable Submitter: 213.190.70.88
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/note/edit/65192
Del: integrated -- http://master.php.net/note/delete/65192/integrated
Del: useless -- http://master.php.net/note/delete/65192/useless
Del: bad code -- http://master.php.net/note/delete/65192/bad+code
Del: spam -- http://master.php.net/note/delete/65192/spam
Del: non-english -- http://master.php.net/note/delete/65192/non-english
Del: in docs -- http://master.php.net/note/delete/65192/in+docs
Del: other reasons-- http://master.php.net/note/delete/65192
Reject -- http://master.php.net/note/reject/65192
Search -- http://master.php.net/manage/user-notes.php