note 65192 deleted from function.preg-replace by bjori
| From: | bjori@php.net | Date: | Wed, 26 Apr 2006 15:37:16 +0000 |
| Subject: | note 65192 deleted from function.preg-replace by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109749@lists.php.net to get a copy of this message | ||
Note Submitter: p dot leblanc at caplaser dot fr
Reason: bad code
----
<?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');
*/
?>