Bubble Sort Algorithm Using PHP

Here’s a snippet in sorting using bubble sort algorithm in PHP

<?php
$num = array(10, 1, 3, 4, 9, 7, 2, 5, 8);

var_dump($num);

for($i=0;$i<count($num)-1;$i++) {
  for($j=$i+1;$j$num[$j]) {
      $temp = $num[$i];
      $num[$i] = $num[$j];
      $num[$j] = $temp;
    }
  }
}

var_dump($num);

$num is the array of integers to be sorted. When sorting done, $num will contain sorted integers in ascending order.