note 83164 deleted from function.usort by cmb

From: Date: Sun, 13 Oct 2019 08:15:15 +0000
Subject: note 83164 deleted from function.usort by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212632@lists.php.net to get a copy of this message
Note Submitter: Ariz Jacinto ---- 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 (#212632) next »