<?php

$arr = [66,4,26,8,0,3,6];
$total = count($arr);

//Version 1
for($j=0; $j<$total;$j++){

    for($i=$j+1;$i<$total;$i++){
echo $i." ".$j." dfd ";
        if($arr[$j] > $arr[$i]){
            $temp = $arr[$i];
            $arr[$i] = $arr[$j];
            $arr[$j] = $temp;
        }
    }
}

//Version 2 using while
$arr = [66,4,26,8,0,3,6];
$i = 0;
$total = count($arr);
while($total > 0){

    $j= $i+1;
    while($j < count($arr)){
       // echo $i." ".$j." dfd ";
        if($arr[$i] > $arr[$j]){
            $temp = $arr[$j];
            $arr[$j] = $arr[$i];
            $arr[$i] = $temp;   
        }
        $j++;
    }

    $i++;
    $total--;
}

print_r($arr);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: