usort within a class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux