Nested foreach statements... how to break out of child and continue parent if a match is found <p>I have an application that is passing a list of system printers to a PHP application. I am trying to set it up to ignore the printers that are basically just "software" printers. As you can see from the code below(which is by no means pretty). That I have an outer(parent) foreach that is looping through the printer list that is provided in a string that is delimited by a "pipe" symbol. Inside of that I have a second(child) foreach, that loops through a list of words that are common in the software printers names (i.e.. Adobe PDF would match the word "PDF")</p> <p>So my question is this, the parent loop works fine, the printers are inserted in the database from the string, however none of my attempts at filtering out the ones that match the keywords have been excluded. So How would you suggest going about breaking out of the "child" foreach to tell the parent to skip that loop?</p> <pre><code>&lt;?php // Set all QUEUE Printers to Unavailable, so we can reset as active only those that are present $SQL = "UPDATE `queues_printers` SET `status`='0' WHERE (`queue_id`='".$_GET['queue']."')"; $result = $mysqli-&gt;query($SQL); // Process Printers $ignore_names = array("PDF","OneNote","Fax","Microsoft XPS Document Writer","RemotePrinter"); $ignoreit=false; $today = date("Y-m-d"); // Get list from $_GET[printers] $printers = explode("|",base64_decode($_GET['printers'])); // Add/Update them foreach ($printers as $printer){ // Check if this printer is to be ignored(i.e.. pdf printers, fax software, and other software printers are not useful) foreach ($ignore_names as $ignored) { if($ignoreit === false){ if (strpos($printer,$ignored) === true) { $ignoreit = true; break; } } } if($ignoreit === true){ $ignoreit = false; continue; } // See if this is an existing printer and update it to available $SQL = "SELECT DISTINCT id FROM queues_printers WHERE queue_id = '".$_GET['queue']."' AND name = '".$printer."'"; $result = $mysqli-&gt;query($SQL); $row_cnt = $result-&gt;num_rows; if ($row_cnt &gt; '0'){ $printer_detail = $result-&gt;fetch_array(MYSQLI_ASSOC); $UpdateSQL = "UPDATE `queues_printers` SET `status`='1', `last_seen`='".$today."' WHERE (`id`='".$printer_detail["id"]."')"; $result2 = $mysqli-&gt;query($UpdateSQL); $result-&gt;close(); } else{ // Otherwise add it $InsertSQL = "INSERT INTO `queues_printers` (`queue_id`, `name`, `status`, `last_seen`) VALUES ('".$_GET['queue']."', '".$printer."', '1', '".$today."')"; $result2 = $mysqli-&gt;query($InsertSQL); } } $mysqli-&gt;close(); ?&gt; </code></pre>