usort within a class
| From: | Peter Lauri | Date: | Wed, 23 Aug 2006 20:13:37 +0000 |
| Subject: | usort within a class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-241059@lists.php.net to get a copy of this message | ||
Hi,
Is it possible to have the compare function in a class? I can not get it to
work, this is pseudo code:
class A {
function getArray() {
//dosomethingandgetanarray
$array = blabla;
usort($array, "$this->myCompareFunction");
//Or maybe "A::myCompareFunction"
}
function myCompareFunction($a, $b) {
//return rajraj depending on $a and $b values
}
}
Right now I have keep the compare function outside of the class like this:
class A {
function getArray() {
//dosomethingandgetanarray
$array = blabla;
usort($array, "$this->myCompareFunction");
}
}
function myCompareFunction($a, $b) {
//return rajraj depending on $a and $b values
}
Best regards,
Peter Lauri