<?php $arr=array(0,1,2,3,4,5); function chazhao2(&$arr,$search,$start,$end){ if($start>$end){ echo '没找到哦'; return ; } $mid=round(($start+$end)/2); if($search>$arr[$mid]){ chazhao2($arr,$search,$mid+1,$end); }elseif($search<$arr[$mid]){ chazhao2($arr,$search,$start,$mid-1); }else{ echo '找到了,查找的下边是:'.$mid; } }; chazhao2($arr,5,0,count($arr)-1); ?>