note 83926 added to function.strcmp
| From: | g-lockatnv-net dot ru at osu1 dot php dot net | Date: | Thu, 19 Jun 2008 06:08:00 +0000 |
| Subject: | note 83926 added to function.strcmp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140577@lists.php.net to get a copy of this message | ||
Here is my function to compare russian words.
You can replace $abc to your alphabet.
function strcmp_rus($str1, $str2)
{
$abc =
"ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐРСТУФХЦЧШЩЪЫЬÐЮЯ
абвгдеÑжзийклмнопÑÑÑÑÑÑ
ÑÑÑÑÑÑÑÑÑÑ";
$len = min(strlen($str1), strlen($str2));
for ($i = 0; $i < $len; $i++)
{
$s1 = strlen($abc);
$s2 = strlen($abc);
for ($j = 0; $j < strlen($abc); $j++) if ($str1[$i] == $abc[$j]) $s1 = $j;
for ($k = 0; $k < strlen($abc); $k++) if ($str2[$i] == $abc[$k]) $s2 = $k;
if ($s1 < $s2) return -1;
else if ($s1 > $s2) return 1;
}
return 0;
}
----
Server IP: 195.54.192.44
Probable Submitter: 127.0.0.1
----
Manual Page -- http://www.php.net/manual/en/function.strcmp.php
Edit -- https://master.php.net/note/edit/83926
Del: integrated -- https://master.php.net/note/delete/83926/integrated
Del: useless -- https://master.php.net/note/delete/83926/useless
Del: bad code -- https://master.php.net/note/delete/83926/bad+code
Del: spam -- https://master.php.net/note/delete/83926/spam
Del: non-english -- https://master.php.net/note/delete/83926/non-english
Del: in docs -- https://master.php.net/note/delete/83926/in+docs
Del: other reasons-- https://master.php.net/note/delete/83926
Reject -- https://master.php.net/note/reject/83926
Search -- https://master.php.net/manage/user-notes.php