diff --git a/php/sort/ahbilalkhan-10P_bubble_sort.php b/php/sort/ahbilalkhan-10P_bubble_sort.php new file mode 100644 index 00000000..66b923b6 --- /dev/null +++ b/php/sort/ahbilalkhan-10P_bubble_sort.php @@ -0,0 +1,26 @@ + $array[$i + 1] ) + { + list( $array[$i + 1], $array[$i] ) = + array( $array[$i], $array[$i + 1] ); + $swap = true; + } + } + } + while( $swap ); + + return $array; +} +$array = array(4,6,2,9,0,1,5,3,8,7); +echo "Original Array :\n"; +echo implode(', ',$array ); +echo "\nSorted Array\n:"; +echo implode(', ',bubbleSort($array)). PHP_EOL;