3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('4','2','3','0'); echo "<pre>";print_r($array); function bubble_sort($array){ $count = $array; for($i=0;$i<$count;$i++){ for($j=0;$j<$count-1-$i;$j++){ if($array[$j+1]<$array[$j]){ swap($array,$j,$j++); } } } return $array; } fuction swap(&$arr,$a,$b){ $temp = $arr[$a]; $arr[$a] = $arr[$b]; $arr[$b] = $temp; } $array1 = bubble_sort($array); print_r($array1);
Output for 5.4.0 - 5.4.31
Parse error: syntax error, unexpected 'swap' (T_STRING) in /in/GX94S on line 31
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/GX94S on line 31
Process exited with code 255.

preferences:
184.13 ms | 1395 KiB | 68 Q