|
Posted by Michael Fesser on 12/13/06 00:38
..oO(Greg D)
>I'm trying to sort an array of objects within an object. Included is a
>dumbed down example so that we can get at the meat of the issue without
>worrying about complexity or validation. Basically, Funk is an object that
>has a name (string) and a value(int). FunkThis represents an object
>containing a list of Funks, with each key corresponding to the name of the
>Funk. I want to sort this list by val, but I get a Warning: usort():
>Invalid comparison function error when I run the script. Keep in mind that
>this is for PHP 4
>[...]
callback
http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback
| A method of an instantiated object is passed as an array containing an
| object as the element with index 0 and a method name as the element
| with index 1.
Since compareFunks() is a method of FunkThis, you need
uasort($list, array($this, 'compareFunks'));
to call it.
Micha
Navigation:
[Reply to this message]
|