I have an array of filenames that I pulled from an FTP folder that include store numbers and a date, such as "Store Evaluation_12345_2019-12-19_0000.pdf". Let's call the array $file_list. I first got all the filenames for the current month ($currentYearMonth = date('Y-m');). Next I extracted the store number and date, and then got a day of the week from the date for each filename, and the consultant assigned to each store:
// Create empty arrays to store our outputs
$SN = array();
$Day = array();
$BC = array();
$SNandDayEvals = array();
foreach($file_list as $eval) {
if ((strpos($eval, '.pdf') !== false) && (strpos($eval, 'Store Evaluation') !== false) && (strpos($eval, $currentYearMonth) !== false)) {
// Extract store number and date
preg_match('/Store Evaluation_(.*?)_(.*?)_/', $eval, $filename);
$EvalStoreNum = $filename[1];
$EvalDate = $filename[2];
// Get day of week from filename date
$EvalDay = date('D', strtotime($EvalDate));
// Convert Store Number to Store's Username
$username = 'shop'.$EvalStoreNum;
// Get store from database by username
$Shop = get_user_by('login', $username);
// Get store's consultant
$assignedBC = $Shop->Group;
// Create new arrays
$SN[] = $EvalStoreNum;
$SNandDayEvals[] = $EvalStoreNum.'_'.$EvalDay;
}
}
Then to make a long story short, I get the consultant's store list (array = $outputBCStores), and check to see which filenames belong to each consultant:
$BCEvalsCompleted = array_intersect($SN, $outputBCStores);
$results = implode('<br>', $BCEvalsCompleted);
return = $results;
This works just fine outputting the list of store numbers by themselves. Now I'm trying to figure out how to add the day of the week next to the store numbers. For example "12345" => "12345 (Thu)".
I have tried changing the following which doesn't work:
$SN[] = array( 'storenumber' => $EvalStoreNum, 'dayofweek' => $EvalStoreNum.' ('.$EvalDay.')');
$BCEvalsCompleted = array_intersect($SN['storenumber'], $outputBCStores);
$results = implode('<br>', $BCEvalsCompleted->$SN['dayofweek']);
Not sure where to go from here. Any help would be greatly appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire