Hi there people of the forum,
(PSUEDO CODE!)
$day = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
$days = count($day);
foreach($day as $key=>$value){
if(preg_match("/".$value."/", end($errorLogContents))){
echo "Match<br>";
if($value != date("l")){
echo "Previous day logged was ".$value." and todays day is ".date("l")."<br>";
}
}
else{
echo "No Match<br>";
}
}
My thought is, I use the count() outside the loop so as not to incur too much parser/cpu load, but then I go on to use end() inside the loop.. Kinda contradictory, and as my file could either hold 5 lines or 500 lines, I would like to know whether or not I should worry about using end() within the loop, of whether assigning it to a variable will take up more memory than repeated calls when the loop is invoked..
I personally think that as the loop is only called 7 times, and once the loop has finished, that 'temp' memory has been released, that the assignment to a var could incur a larger memory usage than the loop - or am I talking/thinking stupidly here.
As it stands it works, but I am trying to write this system for work with efficiency in mind..
Cheers,
MRb