I am preparing upgrade to PHP 8.2 on a big application, and obviously going through changes between PHP 8.1 and 8.2. One of the BC breaking changes mentioned HERE is:
ksort() and krsort() now do numeric string comparison under SORT_REGULAR using the standard PHP 8 rules now.
I don't seem to understand what this means. Since ksort
sorts by keys, I assumed BEFORE it would NOT sort something like this:
[
'-5' => 'minus five',
'4' => 'THIS SHOULD MOVE',
'1' => 'one',
'2' => 'two',
'100' => 'hundred',
];
ksort($arr, SORT_REGULAR);
var_dump($arr);
But I used https://onlinephp.io/ and the it works just fine on 7.x, 8.1 and 8.2.
I tried with SORT_REGULAR
and without.
array(5) {
[-5]=>
string(10) "minus five"
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[4]=>
string(16) "THIS SHOULD MOVE"
[100]=>
string(7) "hundred"
}
Can someone explain to me what am I not understanding here?