while($hero2 = mysqli_fetch_assoc($hero1))
{
$time_now = strtotime($hero2['cron1']);
$time_need = strtotime($hero2['cron2']);
if($time_need>=$time_now ){
$t_s= date("H:i ",75600-($time_need-$time_now));
}
else
$t_s= date("H:i ",75600-($time_now-$time_need));
echo "[".str_replace(":",".",$t_s).",]";
}
$out_arr = array();
while($hero2 = mysqli_fetch_assoc($hero1))
{
$time_now = strtotime($hero2['cron1']);
$time_need = strtotime($hero2['cron2']);
if($time_need>=$time_now ){
$t_s= date("H:i ",75600-($time_need-$time_now));
}
else
$t_s= date("H:i ",75600-($time_now-$time_need));
$out_arr[] = str_replace(":",".",$t_s);
}
echo "[".join(' ,', $out_arr).']';
echo "[";
while($hero2 = mysqli_fetch_assoc($hero1)){
$time_now = strtotime($hero2['cron1']);
$time_need = strtotime($hero2['cron2']);
if ($time_need>=$time_now ){
$t_s= date("H:i ",75600-($time_need-$time_now));
}
else {
$t_s= date("H:i ",75600-($time_now-$time_need));
}
echo str_replace(":",".",$t_s).",";
}
echo "]";
$arr = [];
$show = false;
while ($hero2 = mysqli_fetch_assoc($hero1)) {
$time_now = strtotime($hero2['cron1']);
$time_need = strtotime($hero2['cron2']);
if ($time_need >= $time_now) {
$t_s = date("H:i ", 75600 - ($time_need - $time_now));
}
else {
$t_s = date("H:i ", 75600 - ($time_now - $time_need));
if (!$show) $show = true;
$arr[] = str_replace(":", ".", $t_s);
}
}
if ($show) {
echo '[' . implode(',', $arr) . ']';
}