I don't know how this code is running well.
$on_count=0;
$on_users=array();
foreach ($res as $t_res) {
$dteStart = new DateTime("now");
$dteEnd = new DateTime($t_res["last_seen"]);
$dteDiff = $dteStart->diff($dteEnd);
$y=$dteDiff->format("%Y");
$m=$dteDiff->format("%m");
$d=$dteDiff->format("%d");
$H=$dteDiff->format("%H");
$i=$dteDiff->format("%i");
$s=$dteDiff->format("%s");
$in_sec_res=$y*12*30*24*60*60+$m*30*24*60*60+$d*24*60*60+$H*60*60+$i*60+$s."\n";
$in_sec_cond=3*60;
if ($in_sec_res<$in_sec_cond) {
$on_count=$on_count+1;
$i=0;
foreach($t_res as $t_ress){
if ($i==2) {
$on_users[$on_count]=$t_ress;
//echo $on_names[$on_count]."**\n";
}
$i++;
}
}
}
I want an explanation (inner foreach()
).
Here,
last_seen
is a random DateTime.
Or is there any other way to collect all
$t_res['name']
in an array?