note 83163 added to function.usort

From: Date: Tue, 13 May 2008 17:49:49 +0000
Subject: note 83163 added to function.usort
Groups: php.notes 
Request: Send a blank email to php-notes+get-139336@lists.php.net to get a copy of this message
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; } } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 64.79.222.10 ---- Manual Page -- http://www.php.net/manual/en/function.usort.php Edit -- https://master.php.net/note/edit/83163 Del: integrated -- https://master.php.net/note/delete/83163/integrated Del: useless -- https://master.php.net/note/delete/83163/useless Del: bad code -- https://master.php.net/note/delete/83163/bad+code Del: spam -- https://master.php.net/note/delete/83163/spam Del: non-english -- https://master.php.net/note/delete/83163/non-english Del: in docs -- https://master.php.net/note/delete/83163/in+docs Del: other reasons-- https://master.php.net/note/delete/83163 Reject -- https://master.php.net/note/reject/83163 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139336) next »