note 117564 added to function.soundex

From: Date: Tue, 30 Jun 2015 11:40:01 +0000
Subject: note 117564 added to function.soundex
Groups: php.notes 
Request: Send a blank email to php-notes+get-202996@lists.php.net to get a copy of this message
<?php // https://github.com/Fruneau/Fruneau.github.io/blob/master/assets/soundex_fr.php // http://blog.mymind.fr/blog/2007/03/15/soundex-francais/ 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', 'ï' => '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); } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 37.58.141.113 ---- Manual Page -- http://php.net/manual/en/function.soundex.php Edit -- https://master.php.net/note/edit/117564 Del: integrated -- https://master.php.net/note/delete/117564/integrated Del: useless -- https://master.php.net/note/delete/117564/useless Del: bad code -- https://master.php.net/note/delete/117564/bad+code Del: spam -- https://master.php.net/note/delete/117564/spam Del: non-english -- https://master.php.net/note/delete/117564/non-english Del: in docs -- https://master.php.net/note/delete/117564/in+docs Del: other reasons-- https://master.php.net/note/delete/117564 Reject -- https://master.php.net/note/reject/117564 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202996) next »