3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = [1,2,3,3,44,5,6,2,3,2,33,8,8,6,"Kanyin",9,24,21,3,44,5,102,33,43,"Kanyin", "Kanyinsola", "Adeola", "adeola", "Adeolas", "Adeola1","Adeola"]; bubbleSort($list); function bubbleSort( array $lst ) { $numList = count( $lst ); $swapped = false; do{ $swapped = false; for( $i=0; $i < $numList - 1; $i++ ) { if( $lst[$i] > $lst[$i+1]){ $temp = $lst[$i]; $lst[$i] = $lst[$i+1]; $lst[$i+1] = $temp; $swapped = true; } } } while ( $swapped == true); echo ( implode(" ", $lst)); } //selectionSort( $list ); function selectionSort( array $lst ) { $numList = count( $lst ); for( $i=0; $i < $numList; $i++ ) { $index = 0; $smallest = $lst[$i]; for( $j = $i; $j < $numList; $j++ ) { if( $lst[$j] < $smallest ) { $smallest = $lst[$j]; $index = $j; } $temp = $lst[$i]; $lst[$i] = $smallest; $lst[$index] = $temp; } var_dump($lst); } } //linearSearch( $list, 3 ); function linearSearch( array $lst, $target ) { $numList = count( $lst ); for( $i=0; $i < $numList; $i++ ) { if( $lst[$i] == $target ) { echo "Found $target at $i\n"; } } } //factoral(6); function factoral( $n ) { if( $n == 1 ) { return 1; } echo $n * factoral( $n -1 ); } function chessboard() { for($i=0; $i<6; $i++) { echo "$i X0 :"; for($j=0; $j<$i; $j++) { echo "*"; } echo "\n"; } } //chessboard();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
1 2 2 2 3 3 3 3 5 5 6 6 8 8 9 21 24 33 33 43 44 44 102 Adeola Adeola Adeola1 Adeolas Kanyin Kanyin Kanyinsola adeola
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 1 2 2 2 3 3 3 3 5 5 6 6 8 8 9 21 24 33 33 43 44 44 102 Adeola Adeola Adeola1 Adeolas Kanyin Kanyin Kanyinsola adeola
Output for 7.0.0 - 7.0.25, 7.1.0 - 7.1.20, 7.2.5 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Adeola Adeola Adeola1 Adeolas Kanyin Kanyin Kanyinsola adeola 1 2 2 2 3 3 3 3 5 5 6 6 8 8 9 21 24 33 33 43 44 44 102

preferences:
191.95 ms | 403 KiB | 184 Q