From: [EMAIL PROTECTED] Operating system: Linux RedHat 7.2 PHP version: 4.0.6 PHP Bug Type: Arrays related Bug description: uasort doesn't work with static functions from inside classes to compare
If I have a static function inside a class that does the comparasion of two objects, I haven't found a way of passing a reference to it in uasort (u.*sort). I tried "Classname::function", also "Classname->function". If the function doesn't exists, not even an error is produced, so its very difficult to debug such things. Heres an example of what doesn't work: class TestObj { var $name; function TestObj($name) { $this->name = $name; } /* This is the static comparing function: */ function cmp_obj($a, $b) { $al = strtolower($a->name); $bl = strtolower($b->name); if ($al == $bl) return 0; return ($al > $bl) ? +1 : -1; } } $a[] = new TestObj("b"); $a[] = new TestObj("a"); $a[] = new TestObj("d"); uasort($a, "TestObj::cmp_obj"); printf("<pre>\n"); print_r($a); printf("</pre>\n"); -> Result: NOT SORTED. -- Edit bug report at: http://bugs.php.net/?id=14104&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]