Supposing I have the following array
[Agent - 134] => Array
(
[0] => Array
(
[0] => 2015-07-14 12:03:33.089210
[1] => CONNECT
)
[1] => Array
(
[0] => 2015-07-14 12:03:55.053394
[1] => COMPLETEAGENT
)
[2] => Array
(
[0] => 2015-07-14 12:07:29.913989
[1] => CONNECT
)
[3] => Array
(
[0] => 2015-07-14 12:07:56.693848
[1] => COMPLETECALLER
)
[4] => Array
(
[0] => 2015-07-14 12:09:02.989649
[1] => CONNECT
)
[5] => Array
(
[0] => 2015-07-14 12:09:35.608860
[1] => COMPLETEAGENT
)
[6] => Array
(
[0] => 2015-07-14 12:11:56.564747
[1] => CONNECT
)
[7] => Array
(
[0] => 2015-07-14 12:12:25.979910
[1] => COMPLETEAGENT
)
[8] => Array
(
[0] => 2015-07-14 12:20:15.130092
[1] => CONNECT
)
[9] => Array
(
[0] => 2015-07-14 12:20:45.843112
[1] => COMPLETEAGENT
)
)
And I am trying to calculate the difference between the events. The condition for a complete event is if the previous array's second element is a CONNECT and the next array's second element is either COMPLETEAGENT or COMPLETECALLER. I have written the following code to loop through where for testing purposes my If statement should fulfill the condition yet its the else that works which leads me to believe there might by something wrong in my syntax for the comparison which I'm unsure of.
foreach ($ttt_array as $tKey => $value) {
$ttt_total = 0;
for ($i = 0; $i < count($value);
) {
if (($value[$i][1] === "CONNECT" && $value[$i + 1][1] === "COMPLETEAGENT") || ($value[$i][1] === "CONNECT" && $value[$i + 1][1] === "COMPLETECALLER")) {
$i+=1;
echo $i;
} else {
$srtTime = strtotime($value[$i][0]);
echo "Start-Time" . $srtTime . "<BR>";
$endTime = strtotime($value[$i + 1][0]);
echo "End-Time" . $endTime . "<BR>";
$interval = $endTime - $srtTime;
echo "Interval" . $interval . "<BR>";
$ttt_total += $interval;
$i+=2;
}
}
$ttl_talk_total[$tKey] = timeConverter($ttt_total);
}
Where $ttt_array is the array show above. What is incorrect about the if statement?
Aucun commentaire:
Enregistrer un commentaire