1 回答
TA贡献1784条经验 获得超8个赞
count()不是在循环时回显条件,而是可以将其存储在一个数组中,然后在数组的末尾用 a 输出它$output:
$output = array(); //create an empty array to store our output
foreach($file_list as $file) {
//Only get Current Month PDF files
if ((strpos($file, '.pdf') !== false) && (strpos($file, 'Store Evaluation') !== false) && (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
$output[] = "<strong>".$strippedEvalStoreNum."</strong> (".$strippedEvalDate.")"; //add to array instead of echo
}
}
echo '<strong>'.count($file_list).' Completed Evaluations</strong><br><br>';
echo '<strong>'.count($output).' Evaluations Met My Conditions:</strong><br><br>'; //echo the number of files that met the conditions
echo implode('<br/>', $output); //echo the converted file names
- 1 回答
- 0 关注
- 72 浏览
添加回答
举报