note 30163 added to function.soundex

From: Date: Sat, 08 Mar 2003 23:29:29 +0000
Subject: note 30163 added to function.soundex
Groups: php.notes 
Request: Send a blank email to php-notes+get-45018@lists.php.net to get a copy of this message
eek... hosting got taken down on that server.. here's the code for the previous function cg_sylc($nos){ $nos = strtoupper($nos); $syllables = 0; $before = strlen($nos); $nos = str_replace(array('AA','AE','AI','AO','AU', 'EA','EE','EI','EO','EU','IA','IE','II','IO', 'IU','OA','OE','OI','OO','OU','UA','UE', 'UI','UO','UU'), "", $nos); $after = strlen($nos); $diference = $before - $after; if($before != $after) $syllables += $diference / 2; if($nos[strlen($nos)-1] == "E") $syllables --; if($nos[strlen($nos)-1] == "Y") $syllables ++; $before = $after; $nos = str_replace(array('A','E','I','O','U'),"",$nos); $after = strlen($nos); $syllables += ($before - $after); return $syllables; } function cg_SoundEx($SExStr){ $syl = cg_sylc($SExStr); $SExStr = strtoupper($SExStr); for($i = 1, $ii = 2,print $SExStr[0]; ;$ii++){ if(($SExStr[$i] != $SExStr[$ii])){ $tsstr .= $SExStr[$ii]; $i ++; } if($SExStr[$ii] == false){ break; } } $tsstr = str_replace(array('A', 'E', 'H', 'I', 'O', 'U', 'W', 'Y'), "", $tsstr); $tsstr = str_replace(array('B', 'F', 'P', 'V'), "1", $tsstr); $tsstr = str_replace(array('C', 'G', 'J', 'K', 'Q', 'S', 'X', 'Z', 'Ç'), "2", $tsstr); $tsstr = str_replace(array('D', 'T'), "3", $tsstr); $tsstr = str_replace(array('L'), "4", $tsstr); $tsstr = str_replace(array('M', 'N', 'Ñ'), "5", $tsstr); $tsstr = str_replace(array('R'), "6", $tsstr); while($iii < 3){ if($tsstr[$iii] != false){ $ttsstr .= $tsstr[$iii]; } else { $ttsstr .= "0"; } $iii ++; } $ttsstr .= $syl; print $ttsstr; } -- http://www.php.net/manual/en/function.soundex.php http://master.php.net/manage/user-notes.php?action=edit+30163 http://master.php.net/manage/user-notes.php?action=delete+30163 http://master.php.net/manage/user-notes.php?action=reject+30163

« previous php.notes (#45018) next »