I want to optimize this code block so that it breaks out of the inner loop when stristr() is true.

Here is what I currently have:

foreach ($aData as $key => $row) {
     $iFound = false;
     foreach($row as $cell) {
          foreach ($aSearch as $sTerm) {
               if (stristr($cell, $sTerm)) { $iFound = true; }
          }
     }
     if ($iFound == false) { unset($aData[$key]); } 
}

Is this possible within a foreach loop?

TIA

    Doh...

    For some reason I thought that only worked in While loops

    Thanks.

      No, see quote:

      http://us3.php.net/manual/en/control-structures.break.php wrote:

      break ends execution of the current for, foreach, while, do-while or switch structure.

      Don't forget to mark this topic as resolved please.

      .

        Write a Reply...