<?php
function soundex_fr($sIn){
static $convVIn, $convVOut, $convGuIn, $convGuOut, $accents;
if (!isset($convGuIn)) {
$accents = array('é' => 'E', 'è' => 'E', '?' => 'E', 'ê' => 'E',
'á' => 'A', 'à' => 'A', '?' => 'A', '?' => 'A', '?' => 'A', '?' => 'A',
'?' => 'I', '?' => 'I', 'ì' => 'I', 'í' => 'I',
'?' => 'O', '?' => 'O', 'ò' => 'O', 'ó' => 'O', '?' => 'O', '?' => 'O',
'ú' => 'U', 'ù' => 'U', '?' => 'U', 'ü' => 'U',
'?' => 'C', '?' => 'N', '?' => 'S', '?' => 'E',
'é' => 'e', 'è' => 'e', '?' => 'e', 'ê' => 'e',
'á' => 'a', 'à' => 'a', '?' => 'a', 'a' => 'a', '?' => 'a', '?' => 'a',
'?' => 'i', '?' => 'i', 'ì' => 'i', 'í' => 'i',
'?' => 'o', '?' => 'o', 'ò' => 'o', 'ó' => 'o', '?' => 'o', '?' => 'o',
'ú' => 'u', 'ù' => 'u', '?' => 'u', 'ü' => 'u',
'?' => 'c', '?' => 'n');
$convGuIn = array( 'GUI', 'GUE', 'GA', 'GO', 'GU', 'SCI', 'SCE', 'SC', 'CA', 'CO',
'CU', 'QU', 'Q', 'CC', 'CK', 'G', 'ST', 'PH');
$convGuOut = array( 'KI', 'KE', 'KA', 'KO', 'K', 'SI', 'SE', 'SK', 'KA', 'KO',
'KU', 'K', 'K', 'K', 'K', 'J', 'T', 'F');
$convVIn = array( '/E?(AU)/', '/([EA])?[UI]([NM])([^EAIOUY]|$)/', '/[AE]O?[NM]([^AEIOUY]|$)/',
'/[EA][IY]([NM]?[^NM]|$)/', '/(^|[^OEUIA])(OEU|OE|EU)([^OEUIA]|$)/', '/OI/',
'/(ILLE?|I)/', '/O(U|W)/', '/O[NM]($|[^EAOUIY])/', '/(SC|S|C)H/',
'/([^AEIOUY1])[^AEIOUYLKTPNR]([UAO])([^AEIOUY])/', '/([^AEIOUY]|^)([AUO])[^AEIOUYLKTP]([^AEIOUY1])/', '/^KN/',
'/^PF/', '/C([^AEIOUY]|$)/', '/E(Z|R)$/',
'/C/', '/Z$/', '/(?<!^)Z+/', '/H/', '/W/');
$convVOut = array( 'O', '1\3', 'A\1',
'E\1', '\1E\3', 'O',
'Y', 'U', 'O\1', '9',
'\1\2\3', '\1\2\3', 'N',
'F', 'K\1', 'E',
'S', 'SE', 'S', '', 'V');
}
if ( $sIn === '' ) return ' ';
$sIn = strtr( $sIn, $accents);
$sIn = strtoupper( $sIn );
$sIn = preg_replace( '`[^A-Z]`', '', $sIn );
if ( strlen( $sIn ) === 1 ) return $sIn . ' ';
$sIn = str_replace( $convGuIn, $convGuOut, $sIn );
$sIn = preg_replace( '`(.)\1`', '$1', $sIn );
$sIn = preg_replace( $convVIn, $convVOut, $sIn);
$sIn = preg_replace( '`L?[TDX]?S?$`', '', $sIn );
$sIn = preg_replace( '`(?!^)Y([^AEOU]|$)`', '\1', $sIn);
$sIn = preg_replace( '`(?!^)[EA]`', '', $sIn);
return substr( $sIn . ' ', 0, 4);
}
?>