PHP Bubble Sort

Sort by comparing each adjacent pair of items in a list in turn, swapping the items if necessary, and repeating the pass through the list until no swaps are done.

<?php
function bubble($list, $cycle = 0)
{
  $stop = count($list) - $cycle;
  if ($stop == 0) return $list;

  for ($i = 0; $i < $stop; $i++)
  {
    $next = $i + 1;
    if (isset($list[$next]))
    {
      $temp = $list[$i];
      if ($list[$next] < $list[$i])
      {
        $list[$i] = $list[$next];
        $list[$next] = $temp;
      }
    }
  }

  $cycle++;
  return bubble($list, $cycle);
}
?>