$arr=array('1','7','9','11','20','23','33','44','50');
$len=count($arr);
$low=0;$high=$len-1;
while($low<$high)
{
$mid=intval(($low+$high)/2);
echo $mid.'<br/>';
if($arr[$mid]>9)
{
$high=$mid-1;
}
else
{
$low=$mid+1;
}
}