Re: Hi all! How to rite a cmp function for usort()?
| From: | Richard Lynch | Date: | Thu, 09 Aug 2001 20:55:25 +0000 |
| Subject: | Re: Hi all! How to rite a cmp function for usort()? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62084@lists.php.net to get a copy of this message | ||
>my ISP doesn´t support natcasesort(),
>can anybody tell me how to write a cmp function?
>I couldn´t find a documentaton about it.
function usort_text($value1, $value2){
if ($value1 == $value2){
$result = 0;
}
elseif ($value1 < $value2){
$result = -1;
}
else{ # $value1 > $value2
$result = 1;
}
return $result;
}
You'll probably need more complex accessing/tests for the ==, <, and >
expressions.
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm