hi all...
how do i refer to a sorting function in a class..
function cmp ($a, $b) { if ($a[0] == $b[0]) return 0; return ($a[0] < $b[0]) ? -1 : 1; } //call: usort($r, "cmp");
obviously i can not use usort($r, "$this->cmp");
thanks...
Hi!
Do it like this if you operate on an object of the class:
usort($r, array(&this, 'cmp'));
or like this if you don`t operate on an object of the class:
usort($r, array('ClassName', 'cmp'));
Look at Example 3. usort() example using a member function of an object
Sorry it was a typo in my post. The first sample should bee.
usort($r, array(&$this, 'cmp'));
right - thanks...