<?php
$example = array(
"ae1" => 1,
"ae2" => 2,
0 => 3,
1 => 4,
);
ksort($example);
echo "Sort By Key:";
print_r($example);
krsort($example);
echo "Reverse Sort By Key";
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] => 2
)
Reverse Sort By KeyArray
(
[ae2] => 2
[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] => 2
[0] => 3
[1] => 4
)
Reverse Sort By KeyArray
(
[1] => 4
[ae2] => 2
[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] => 2
[0] => 3
[1] => 4
)
Reverse Sort By KeyArray
(
[1] => 4
[0] => 3
[ae2] => 2
[ae1] => 1
)
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
- Sort By Key:Array
(
[ae1] => 1
[0] => 3
[ae2] => 2
[1] => 4
)
Reverse Sort By KeyArray
(
[1] => 4
[ae2] => 2
[0] => 3
[ae1] => 1
)
preferences:
199.99 ms | 402 KiB | 225 Q