title: PHP: IF statement works on its own, but not inside WHILE loop
body: <p>The problem:</p>
  
  <p>Let's say I have $keyword = a sentence entered into a search box, such as "large white boxes"</p>
  
  <p>What I need to do is break this into individual words, and then test each word to make sure a * doesn't appear within the first 3 letters.  (So, sen* would be ok, but se* would NOT be ok).  If a * does appear in first 3 letters of any individual word, then the "if ($keyword) ..." process needs to end.</p>
  
  <pre><code>if ($keyword)  {
  
  
              $token = strtok($keyword, " ");
                  while ($token != false) {
                      echo $token;
                          if (stripos($token,"*") &lt; 3 ) {
                          return;
                          }
                      $token = strtok(" ");
                      }
  </code></pre>
  
  <p>...code continues...</p>
  
  <p>As you can see, I am echoing each time to see it processing.</p>
  
  <p>If I get rid of the 'if' code, then it outputs 'largewhiteboxes' and continues on as expected.</p>
  
  <p>If I leave the 'if' code as-is, only 'large' is output, and the routine ends - even though the condition has not been met!</p>
  
  <p>If I run that 'if' statement on its own, outside of the WHILE loop, it works just fine, responding true to a * in first 3 positions, and false for everything else...</p>
  
  <p>What might I be doing wrong with this???</p>