note 55364 added to function.soundex
| From: | a4_perfect at mail dot ru | Date: | Mon, 01 Aug 2005 13:18:03 +0000 |
| Subject: | note 55364 added to function.soundex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92866@lists.php.net to get a copy of this message | ||
Even be rewritten, function of [administrator at zinious dot com] is slower than soundex() for
approx 30 times:
<?php
function MakeSoundEx($stringtomakesoundexof)
{
$temp_Name = strtoupper($stringtomakesoundexof);
$SoundKey = array(1=>"BPFV", "CSKGJQXZ", "DT", "L",
"MN", "R", "AEHIOUWY");
$temp_Last = "";
$temp_Soundex = substr($temp_Name, 0, 1);
for ($x = 1; $x <= sizeof($SoundKey); $x++)
for ($i = 0; $i < strlen($SoundKey[$x]); $i++)
if ($temp_Soundex == substr($SoundKey[$x], $i - 1, 1))
$temp_Last = (string)($x==7?"":$x);
for ($n = 1; $n < strlen($temp_Name); $n++)
if (strlen($temp_Soundex) < 4)
{
for ($x = 1; $x <= sizeof($SoundKey); $x++)
for ($i = 0; $i < strlen($SoundKey[$x]); $i++)
if (substr($temp_Name, $n-1, 1)==substr($SoundKey[$x], $i-1, 1))
{
if($x<7 && $temp_Last!=(string)$x)
$temp_Soundex = $temp_Soundex.$x;
$temp_Last = (string)($x);
}
}
return $temp_Soundex . str_repeat("0", 4-strlen($temp_Soundex));
}
?>
----
Submitter IP: 195.248.191.91
----
Manual Page -- http://www.php.net/manual/en/function.soundex.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55364
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55364&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55364&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55364&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55364&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55364&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55364&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55364&report=yes
Search -- http://master.php.net/manage/user-notes.php