View Single Post
Old 23-10-2006, 02:04   #4 (permalink)
tobor
Senior Member
 
tobor's Avatar
 
Join Date: Apr 2005
Location: Toronto, Canada
Posts: 162
PHP Code:
// create function to remove accents
    
function removeAccents($remove_from)
    {
        
// Remove all instances of accents
        
$accent_array = array(
            
'e' => array('é','è','ê','ë'),
            
'E' => array('É','È','Ê','Ë'),
            
'a' => array('á','à','â','ä','å'),
            
'A' => array('Á','À','Â','Ä','Å')
        );
        foreach(
$accent_array as $acc_key => $acc_val_array)
        {
            
$reg_exp_accent '';// clear regular expression var
            
for($m=0;$m<count($acc_val_array);$m++)
            {
                
$reg_exp_accent .= $acc_val_array[$m].'|';// create the regular expression var
            
}
            
$reg_exp_accent substr_replace($reg_exp_accent,"",-1);// remove last '|'
            
            
$remove_from ereg_replace($reg_exp_accent,$acc_key,$remove_from);
        }
        
        return 
$remove_from;
    } 

not the greatest thing ever, but working...

Example of use:
PHP Code:
removeAccents($_POST['french_text']); 
  Reply With Quote