note 83163 deleted from function.usort by felipe

From: Date: Wed, 14 May 2008 18:22:44 +0000
Subject: note 83163 deleted from function.usort by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139386@lists.php.net to get a copy of this message
Note Submitter: acjacinto at gmail dot com ---- Here's how to use usort() within a class using a static function as a callback (using the example above): <?php class MyObj { var $name; function SampleObj($name){ $this->name = $name; usort($this->name, array(&$this, "compareValues")); } static function compareValues($a, $b){ $al = strtolower($a->name); $bl = strtolower($b->name); if ($al == $bl) { return 0; } return ($al > $bl) ? +1 : -1; } } ?>

« previous php.notes (#139386) next »