note 128589 added to function.strnatcmp
| From: | shewa12kpi at gmail dot com | Date: | Tue, 06 Jun 2023 05:39:06 +0000 |
| Subject: | note 128589 added to function.strnatcmp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220546@lists.php.net to get a copy of this message | ||
A simple example using Spaceship Operator (<=>)
<?php
$arr = [100, 4, 6, 50, 9];
uasort($arr, function($a, $b) {
// It will return 0, -1, 1 based on the comparison
return $a <=> $b;
});
echo "<pre>";
print_r($arr);
// Output
Array
(
[1] => 4
[2] => 6
[4] => 9
[3] => 50
[0] => 100
)
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 119.148.8.83)
----
Manual Page -- https://php.net/manual/en/function.strnatcmp.php
Edit -- https://main.php.net/note/edit/128589
Del: integrated -- https://main.php.net/note/delete/128589/integrated
Del: useless -- https://main.php.net/note/delete/128589/useless
Del: bad code -- https://main.php.net/note/delete/128589/bad+code
Del: spam -- https://main.php.net/note/delete/128589/spam
Del: non-english -- https://main.php.net/note/delete/128589/non-english
Del: in docs -- https://main.php.net/note/delete/128589/in+docs
Del: other reasons-- https://main.php.net/note/delete/128589
Reject -- https://main.php.net/note/reject/128589
Search -- https://main.php.net/manage/user-notes.php