function binary_search(array $arr,$num){
$low = 0;
$high = count($arr) - 1 ;
while ($low <= $high) {
$mid = floor(($low+$high)/2);
if($num == $arr[$mid]){
return $mid;
}elseif($num < $arr[$mid]){
$high = $mid - 1;
}else{
$low = $mid + 1;
}
}
return false;
}
$data = array(8,14,55,67,145,218,237,284);
var_dump(binary_search($data,55));