note 16909 added to function.soundex

From: Date: Sun, 18 Nov 2001 20:47:10 +0000
Subject: note 16909 added to function.soundex
Groups: php.notes 
Request: Send a blank email to php-notes+get-20982@lists.php.net to get a copy of this message
But i prefer to use the faster php soundex and adapt it for mySQL. Here is the solution and it works in german language also! function soundex2($str){ $Word=ereg_replace(" ","",$Modell); for($i=0;$i<strlen($Word);$i=$i+3)$SoundexCode.=ereg_replace("[0A-Z]","",soundex(substr($Word,$i,4))); for($n=0;$n<strlen($SoundexCode);$n++)for($i=1;$i<9;$i++)$SoundexCode=ereg_replace("$i$i","$i",$SoundexCode); return $SoundexCode; } //Example $database="YOUR_DB"; $table="YOUR_TABLE"; $row="YOUR_TABLE_ROW"; $MyText="example soundex code"; $SoundexCode=soundex2($MyText); $result=@mysql_db_query($database,"SELECT from $table WHERE SOUNDEX($row) LIKE '%$SoundexCode%'"; If you echo $SoundexCode from $MyText, you receive 251425323 -- http://www.php.net/manual/en/function.soundex.php http://master.php.net/manage/user-notes.php?action=edit+16909 http://master.php.net/manage/user-notes.php?action=delete+16909 http://master.php.net/manage/user-notes.php?action=reject+16909

« previous php.notes (#20982) next »