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:"; print_r($example); krsort($example); echo "Reverse Sort By Key"; print_r($example);
based on mHiTg
Output for 7.0.0 - 7.3.0rc4
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.3.20 - 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 )