2. When the element $search doesn't exist your program breaks
3. You always check array for value $middle, so $middle should have the range 0 <= $middle < length($array). But according to the comment $start cannot be zero. If so, then $middle is always larger than zero, and as such, the first element of the array is never considered.
1. You get a division by zero when $start == $end
2. When the element $search doesn't exist your program breaks
3. You always check array for value $middle, so $middle should have the range 0 <= $middle < length($array). But according to the comment $start cannot be zero. If so, then $middle is always larger than zero, and as such, the first element of the array is never considered.
So it's pretty buggy.