title: Trying to spit sentence into array with words
body: <p>I am trying to split a sentence into an array with words, one word as each element, in PHP if there is more than one word in the sentence. If there is only one word in the sentence, then I just print that one word.</p>
  
  <p>My issue is when I split the sentence into words delimited by a space and put the contents into an array. I do this all using explode. But when I run through the array that explode apparently makes, it says there is nothing in the array when I try to print each item.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>if(isset($_GET['check'])){
      $input = trim($_GET['check']);
      $sentence='';
      if(stripos($input, ' ')!==false){
          $sentence = explode(' ', $input);
          foreach($sentence as $item){
               echo $item;
          }
      }
      else{
          echo $input;
      }
  }
  </code></pre>
  
  <p>Why is <code>echo $item;</code> printing nothing? Why isn't there anything in the array $sentence?</p>