3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on HqGH5
Output for 7.0.0 - 7.1.8
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 hhvm-3.10.1 - 3.21.0
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 4.3.10 - 4.4.9, 5.0.2 - 5.6.30
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 )