Hi,

I think I am in a muddle

I have several nested if{}'s and else{}'s within a while{}
the logic seemed to be right ... but on doing the else{}
the script doesn't seem to hit the end while "}" and continue
with the while loop .

Here is my code:

PHP Code:
$i=0;
while(
$i<=$input_words_cnt){
        if(!
in_array($input_words[$i], $theos_words)) {
            
$j $i+1;
            echo 
"<br>Did NOT find \"$input_words[$i]\" in Theos";
            
$phrase1 "$input_words[$i] $input_words[$j]";
            if(!
in_array($phrase1$theos_words)) {  // checking 2 word phrase
                
$k $j+1;
                echo 
"<br>Did NOT find \"$phrase1\" in Theos";
                
$phrase2 "$input_words[$i] $input_words[$j] $input_words[$k]";
                if(!
in_array($phrase2$theos_words)) {     // checking 3 word phrase
                    
$l $k+1;
                    echo 
"<br>Did NOT find \"$phrase2\" in Theos";
                    
$phrase3 "$input_words[$i] $input_words[$j] $input_words[$k] $input_words[$l]";
                    if(!
in_array($phrase3$theos_words)) { // checking 4 word phrase
                        
echo "<br>Did NOT find \"$phrase3\" in Theos";
                        
$new_words[] = $phrase3;
                        require_once (
"auto_theos_fm2.php");
                        exit;    
                        }
                    else { 
                        echo 
"<br>Found \"$phrase3\" in Theos<br>"$i=$i+4;
                        }    
                    }
                else { 
                    echo 
"<br>Found \"$phrase2\" in Theos<br>"$i=$i+3;
                    }        
                }
            else { 
                echo 
"<br>Found \"$phrase1\" in Theos<br>"$i=$i+2;
                }
            }
        else { 
            echo 
"<br>Found \"$input_words[$i]\" in Theos<br>"$i=$i+1;
            }
        }  
// END while 
When $phrase1 is found ( and it branches to the else{}
the script stops and does not continue with the while loop

( probably have the same problem with $phrase2 and $phrase3
but haven't got that far yet !! )

Not sure how I should structure this

Any help appreciated


.