title: How to make a PHP code run only once
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2743414/how-can-i-execute-a-block-of-code-exactly-once-in-php">How can I execute a block of code exactly once in PHP?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a code that basically checks the current category assigned to the post, and retrieve a code according to it. 
  If there are more then 1 categories assigned to the post, it's rendering both the codes or the same one twice..<br>
  I wondered if there's an option to make the code to work only once.  </p>
  
  <pre><code>&lt;?php 
  foreach((get_the_category()) as $category){ 
    if($category-&gt;cat_ID == '4'){ 
      echo "....TEXT...."; 
    } else { 
      echo "....TEXT2....";
    }
  }
  ?&gt;
  </code></pre>
  
  <p>Thanks!</p>