NYCPHP Meetup

NYPHP.org

[nycphp-talk] Callback function in a class

Dan Cech dcech at phpwerx.net
Wed Jun 22 19:07:34 EDT 2005


corey szopinski wrote:
> I have a need to use a callback function from uasort within a class, and I¹m
> having a hard time figuring out how to pass the name of the custom sort
> method in as the second parameter (it¹s a string... not a reference).
> 

snip

> 
> So, in the code 
> 
> uasort($stores, 'sortDistance');
> 
> doesn't work

You need:

uasort($stores,array(&$this,'sortDistance'));

You can read more about the syntax for callbacks here:

http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback

Dan



More information about the talk mailing list