title: PHP, Echo only one time in a foreach loop
body: <p>i'have an array, and then i have a script who gets the category i'm browsing (using wordpress) and put it in the $category variable.</p>
  
  <p>So i test if the category i'm browsing it's equal to the $array key and then i paste some text </p>
  
  <pre><code>$array = array ('key' =&gt; 'value', ... )
  
  //...
  // a script who gets the category i'm browsing and store it in the $category variable    
  //...
  /* starting the foreach loop */
  foreach( $array as $key =&gt; $value) {
              if ($category == $key) {
                  echo "some $value here";    
              } elseif ($category !== $key) {
                  echo "nothing"; 
              }
  </code></pre>
  
  <p>The problem is that this loop does <strong>echo "nothing"</strong> for each time the $category is not equal to the $key for each element of the array. </p>
  
  <p>So if i have 20 key => value in the array this loop paste one time "some $value here" and 19 times "nothing"</p>
  
  <p>there is a way to echo "nothing" only one time?</p>
  
  <p>Thank you!</p>