note 125739 added to function.uksort

From: Date: Fri, 29 Jan 2021 19:17:34 +0000
Subject: note 125739 added to function.uksort
Groups: php.notes 
Request: Send a blank email to php-notes+get-219162@lists.php.net to get a copy of this message
This might be obvious to many, but just to help others that are trying to use this in a class. Inside a class, you can prefix the function with self:: within the uksort(), and it will work. Also, if it is in another class that is included, you can prefix it with the class name. class someclass { private function ArraySortCMPIP($a, $b) { $a = ip2long($a); $b = ip2long($b); if ($a == $b) return 0; return ($a < $b) ? -1 : 1; } // Output public function PrintResults() { uksort($this->someIPAddressArray, 'self::ArraySortCMPIP'); print_r($this->someIPAddressArray); } } ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.166 (proxied: 166.216.158.43) ---- Manual Page -- http://php.net/manual/en/function.uksort.php Edit -- https://master.php.net/note/edit/125739 Del: integrated -- https://master.php.net/note/delete/125739/integrated Del: useless -- https://master.php.net/note/delete/125739/useless Del: bad code -- https://master.php.net/note/delete/125739/bad+code Del: spam -- https://master.php.net/note/delete/125739/spam Del: non-english -- https://master.php.net/note/delete/125739/non-english Del: in docs -- https://master.php.net/note/delete/125739/in+docs Del: other reasons-- https://master.php.net/note/delete/125739 Reject -- https://master.php.net/note/reject/125739 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#219162) next »