title: if repeating response in foreach in while loop
body: <p>I have an if in a foreach in a while loop. I'm searching for a string in another string of text.</p>
  
  <pre><code>$base = 'someurl';
  $url = $base;
  while(1){
      $json = json_decode(file_get_contents($url));
      $more = $json-&gt;next_page;
      $next = $json-&gt;next_page_number;
  
      if($more){
          $url = $base.'&amp;page='.$next;
      }else{
          break;
      }
  
      foreach($json as $data){
          $c = $data-&gt;text; // search in
          $s = 'string';
          $t = 'prefix1'.$s; // search for
          $m = 'prefix2'.$s; // search for
  
          if( (strpos($c, $t) || strpos($c, $m)) !== false ){
              echo '&lt;p&gt;hello, i found one or more ($t and/or $m) of the search criteria in the text string $c .&lt;/p&gt;';
              break;
          }
      }
  }
  </code></pre>
  
  <p>The problem is that I get the echo from the if statement twice  :(</p>
  
  <p>What I want to achieve is to only make the echo happen ONCE, if $t and/or $m is present in $c.</p>