title: Echo once per foreach
body: <p>So I have the following code:</p>
  
  <pre><code>$colors=$ex-&gt;Get_Color("images/avatarimage3.png", $num_results, $reduce_brightness, $reduce_gradients, $delta);
  foreach ( $colors as $hex =&gt; $count )
  {
      if ($hex == 'e6af23' &amp;&amp; $count &gt; 0.05) 
      { 
          echo "The image has the correct colour"; 
      } 
      else 
      { 
          echo "The image doesn't have the correct colour"; 
      }
  }
  </code></pre>
  
  <p>Basically this code at the moment grabs the hex value and percentage of colours than image contains and adds them to an array. The code above looks to see if the hex is a certain value and the percent above 5% and if it is then it displays the success message. This part works exactly as it should do!</p>
  
  <p>Now, what I also want is that if the colour isn't correct, so for all other hex values in the array other than $hex == 'e6af23' I want it to display a failure message but only display it once and not for every time the hex isn't that value.</p>
  
  <p>Basically I need it so that the failure message is only displayed once and not 5 times (the number of hex colours in the image).</p>