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 關注
- 86 瀏覽
添加回答
舉報