title: Display count of files/items that match specific conditions before listing those items
body: <p>I can't seem to find the answer anywhere. I'm trying to count the number of files in an FTP folder that meet certain conditions. I am using the following:</p>
  
  <pre><code>/*
   * Filename examples: 
   * Store Evaluation_10950_2019-12-03_6980.pdf
   * Store Survey_13532_2019-11-29.pdf
   */
  
  $file_list = ftp_nlist($ftp_connection, "."); 
  $currentDate = date('Y-m');
  
  $countFiles = count($file_list);
  
  // Title of Completed Evaluatons
  echo '&lt;strong&gt;'.$countFiles.' Completed Evaluations:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;'; 
  
  foreach($file_list as $file) {
  //Only get Current Month PDF files
      if ((strpos($file, '.pdf') !== false) &amp;&amp; (strpos($file, 'Store Evaluation') !== false) &amp;&amp; (strpos($file, $currentDate) !== false)) {
          // Remove Store Evaluation_ from string
          $strippedEvals1 = ltrim($eval, 'Store Evaluation_');
          // Remove store number from string
          $strippedEvals2 = strstr($strippedEvals1, '_');
          // Remove _ from string
          $strippedEvals3 = str_replace('_','',$strippedEvals2);
          // Remove everything after the date in string
          $strippedEvalDate = substr_replace($strippedEvals3 ,"", -8); 
          // Get just the store number
          $strippedEvalStoreNum = substr($strippedEvals1, 0, strpos($strippedEvals1, "_")); 
          // Print store number and date
          echo "&lt;strong&gt;".$strippedEvalStoreNum."&lt;/strong&gt; (".$strippedEvalDate.")&lt;br&gt;";
      }
  }
  </code></pre>
  
  <p>I am able to list all of the files according to the conditions I specified; however, now I want to count them and say how many there are at the top. The code above obviously outputs the number of all files in the folder without the conditions.</p>
  
  <p>I have tried <code>$countFiles = count(strpos($file_list, '.pdf'));</code> just to test a single condition, but that produces nothing. What is the correct way to go about this?</p>