<?php
$example = array(
"ae1" => 1,
"ae2" => 2,
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.4, 8.3.6
- Sort By Key:
Array
(
[0] => 3
[1] => 4
[ae1] => 1
[ae2] => 2
)
Reverse Sort By Key:
Array
(
[ae2] => 2
[ae1] => 1
[1] => 4
[0] => 3
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Sort By Key:
Array
(
[0] => 3
[1] => 4
[ae1] => 1
[ae2] => 2
)
Reverse Sort By Key:
Array
(
[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 Key:
Array
(
[1] => 4
[ae2] => 2
[ae1] => 1
[0] => 3
)
- Output for 7.0.0 - 7.0.31, 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
- Sort By Key:
Array
(
[ae1] => 1
[ae2] => 2
[0] => 3
[1] => 4
)
Reverse Sort By Key:
Array
(
[1] => 4
[0] => 3
[ae2] => 2
[ae1] => 1
)
- Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9, 5.0.2 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
- Sort By Key:
Array
(
[ae1] => 1
[0] => 3
[ae2] => 2
[1] => 4
)
Reverse Sort By Key:
Array
(
[1] => 4
[ae2] => 2
[0] => 3
[ae1] => 1
)
- Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
- Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g5G3T on line 11
Sort By Key:PHP_EOLArray
(
[ae1] => 1
[0] => 3
[ae2] => 2
[1] => 4
)
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/g5G3T on line 14
Reverse Sort By Key:PHP_EOLArray
(
[1] => 4
[ae2] => 2
[0] => 3
[ae1] => 1
)
preferences:
272.28 ms | 402 KiB | 415 Q