$server = new MailDownload($mailServerShort, 993, $email, $emailPassword); $attachmentPathNames = $server->downloadAttachment($savedirpath); //var_dump($attachmentPathNames); /* * 1.1take information header information (Date,Group) from csv files. */ include_once './lib/FileWorks.php'; foreach ($attachmentPathNames as $key => $attachmentPathName) { $dateAndGroup = array(); foreach ($subjectFilters as $key1 => $subjectFilter) { // echo 'Path: '.$attachmentPathName[1].' Subject: '.$subjectFilter.' Poss: '.strpos($attachmentPathName[1], $subjectFilter).PHP_EOL; if (strpos($attachmentPathName[1], $subjectFilter) > 0 || strpos($attachmentPathName[1], $subjectFilter) === 0) { $attachmentPathNames[$key][1] = $subjectFilter; $files = new FileWorks(); echo 'File: ' . $attachmentPathName[0] . ' Line Date: ' . $lineStart[$key1][0] . ' Line Group: ' . $lineStart[$key1][1] . PHP_EOL; $dateAndGroup = $files->getDateAndGroup($attachmentPathName[0], $key1, $lineStart); } } if (isset($dateAndGroup[1])) { if ($dateAndGroup[0] != "") { $attachmentPathNames[$key][3] = $dateAndGroup[0]; } if ($dateAndGroup[1] != "") { $attachmentPathNames[$key][4] = $dateAndGroup[1]; } } } /* * Remove the files that have no date or do not have the right subject * **/ foreach ($attachmentPathNames as $key => $value) {