On Thu, 2006-08-24 at 03:13 +0700, Peter Lauri wrote:
> 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
> }
> 

RTF :)

usort( $array, array( $this, 'myCompareFunction' ) )

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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

Reply via email to