PHPverse 2025

Voting

: five minus two?
(Example: nine)

The Note You're Voting On

smcbride at msn dot com
4 years ago
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);
}
}

<< Back to user notes page

To Top