php - Opposite condition producing required results in If Else statement -
supposing have 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 trying calculate difference between events. condition complete event if previous array's second element connect
, next array's second element either completeagent
or completecaller
. have written following code loop through testing purposes if statement should fulfill condition yet else
works leads me believe there might wrong in syntax comparison i'm unsure of.
foreach ($ttt_array $tkey => $value) { $ttt_total = 0; ($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
array show above. incorrect if statement?
"compeleteagent" <== error? "compeletecaller" <== this
Comments
Post a Comment