[PHP]
PHP Code:
int bs(int array[],int n,int key)
{
    
int mid,low=0,high=(n-1);
    
mid=n/2;
    
printf("high:%d--low:%d\n",high,low);
    if(array[
mid] == key)
    {
        return(
mid);
    }
    if(array[
mid]>key)
    { 
         
printf("mid>key\t");printf("array[mid]=%d--mid=%d\n",array[mid],mid);
        return(
bs(&(array[0]),mid,key));
    }
    if(array[
mid]<key)
    {
                      
printf("mid<key\n");printf("array[mid]=%d--mid=%d\n",array[mid],mid);
        return(
bs(&(array[mid+1]),mid,key));
    }
    if(
high low)
    {
         return(-
1);
    }
    else{
         return(-
1);
    }

This one work for all exit element but there is not condition to stop when element now exit!??
Please test it and help.I really need it before next midnight.