Here is my code : 

```
    <?php
    $a=array(10,8,6,5);
    $b=count($a);
    for($i=0;$i<($b-1);$i++)
    {
        for($j=1;$j<($b);$j++)
        {
            if($a[$j]<$a[$i])
            {
            $temp = $a[$j];
            $a[$j]=$a[$i];
            $a[$i]=$temp;
            }

        }

    }

```

I just want to know what's wrong in the above code ? because if i take 3 array values it works fine but for 4 its not working....can someone do the modification for the same code,and also please briefly explain why is it not working any issues with looping?I am not looking for different code.