title: how to filter the output of an array produced with a foreach loop
body: <p>For reading all <code>.txt</code> files in a directory, i use code blow:</p>
  
  <pre><code>// Grab all the files from subscribers dir
  $dir = 'subscribers/';
  if ($dh = opendir($dir)) {
      while(($file = readdir($dh))!== false){
          if ($file != "." &amp;&amp; $file != "..") { // This line strips out . &amp; ..                                     
                  $all_subscribers[] = $file;   // put all files in array 
          }
      }           
  }
  closedir($dh);
  asort($all_subscribers);
  </code></pre>
  
  <p>Each txt file has 4 lines and looks like this:</p>
  
  <pre><code>id-12345678 // id
  Friends // name of category
  John // name subscriber
  john.smith@gmail.com // email subscriber
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>foreach($all_subscribers as $file) { 
      // open and prepare files
      $all_subscribers_files = 'subscribers/'.$file;          
      // get data out of txt file     
      $lines = file($all_subscribers_files, FILE_IGNORE_NEW_LINES); // set lines from all files into an array 
      $recipients_category = $lines[1];               
      $recipients_name = $lines[2]; //  name of recipients
      $recipients_email = $lines[3]; //  email of the recipients                  
      //$mail-&gt;AddCC($recipients_email, $recipients_name);                            
  }
  </code></pre>
  
  <p>When i echo <code>$recipients_email</code> it shows me all the email-addresses form all subscribers.</p>
  
  <p>When i echo <code>$recipients_category</code>, it shows me all the categories form each subscriber.
  I have 5 categories: <code>Friends, Collegas, Family, Club and Offside</code></p>
  
  <p>How can i strip out the emails corresponding to <code>Offside</code> category?
  So when i <code>echo $recipients_email;</code> it should give me all the email-addresses from all categories except from <code>Offside</code> category... </p>