Binary search in PHP