These values should be in an array, for many reasons. For one, your code could be simply:
foreach (pubDate_arr as $date) {
if ($date < $lastrun) {
$body.= "Not updated.\n\n";
break;
}
}
Even if you insist on the "$var1", "$var2", etc. style, you could name them more consistently with the first one being "$pubDate0" instead of just "$pubDate". Then your code could be:
for ($i = 0; $i <= 5; $i++) {
if (${pubDate . $i} < $lastrun) {
$body.= "Not updated.\n\n";
break;
}
}
Your code won't work because you have to compare each item individually, not as a group. Doing it the way you're trying to, the code would be:
if (($pubDate >= $lastrun) && ($pubDate1 >= $lastrun) && ($pubDate2 >= $lastrun) && ($pubDate3 >= $lastrun) && ($pubDate4 >= $lastrun) && ($pubDate5 >= $lastrun)) {
} else {
$body.= "Not updated.\n\n";
}
Of course, using "||" instead of "&&" will speed up your code (very) slightly and, imo, be more logical:
if (($pubDate < $lastrun) || ($pubDate1 < $lastrun) || ($pubDate2 < $lastrun) || ($pubDate3 < $lastrun) || ($pubDate4 < $lastrun) || ($pubDate5 < $lastrun)) {
$body.= "Not updated.\n\n";
}