3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function array_swap(&$input, $num) { $tmp = $input[0]; $input[0] = $input[$num]; $input[$num] = $tmp; } $input = [4, 5, 8, 9, 1, 7, 2]; function xsort($oldArray) { $newArray = array(); foreach($oldArray as $arr){ $newArray[] = $arr; } return $newArray; } var_dump(xsort($input));