modify loop to display message 1 time for all instances
<p>My code check the 1st 3 messages of the twitter wall and looks for a string called "code". if its there it will echo "code available" and if its not it will echo "no code". Right now it echos 3 times for each message.</p>

<p>how would i modify this code to check all 3 messages still, but only echo the "no code" or "code available" message one time for all wall posts?</p>

<pre><code>function echo_messages($url,$max = 1)
{
     $data = json_decode(file_get_contents($url));
     $counter = 0;
     foreach($data-&gt;data as $post) 
     {
        preg_match("/code/", $post-&gt;message, $code);        
        echo '&lt;div id="facebook"&gt;';
        if (strlen($code[0]) == 0){
            echo 'Facebook: No Code';
        }else{
            echo 'Facebook: Code Available';
        }
        echo '&lt;/div&gt;';
       $counter++;
       if($counter &gt;= $max)
       {
           return true;
       }
    } 
}
echo_messages('https://graph.facebook.com/234265435775/posts',3);
</code></pre>
