<?php
$example = array(
"ae1" => 1,
"ae2" => 3,
0 => 3,
1 => 4,
);
ksort($example);
echo "Sort By Key:" . PHP_EOL;
print_r($example);
krsort($example);
echo "Reverse Sort By Key:" . PHP_EOL;
print_r($example);
- Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Sort By Key:
Array
(
[0] => 3
[1] => 4
[ae1] => 1
[ae2] => 3
)
Reverse Sort By Key:
Array
(
[ae2] => 3
[ae1] => 1
[1] => 4
[0] => 3
)
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
- Sort By Key:
Array
(
[ae1] => 1
[ae2] => 3
[0] => 3
[1] => 4
)
Reverse Sort By Key:
Array
(
[1] => 4
[ae2] => 3
[ae1] => 1
[0] => 3
)
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- Sort By Key:
Array
(
[ae1] => 1
[ae2] => 3
[0] => 3
[1] => 4
)
Reverse Sort By Key:
Array
(
[1] => 4
[0] => 3
[ae2] => 3
[ae1] => 1
)
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
- Sort By Key:
Array
(
[ae1] => 1
[0] => 3
[ae2] => 3
[1] => 4
)
Reverse Sort By Key:
Array
(
[1] => 4
[ae2] => 3
[0] => 3
[ae1] => 1
)
preferences:
193.14 ms | 402 KiB | 213 Q