[Solved] how to sum the array time [closed]


$totalTimeSecs = 0;
foreach ($array as $l1) { // Loop outer array
  foreach ($l1 as $l2) { // Loop inner arrays
    if (isset($l2['jQuery']['length'])) { // Check this item has a length
      list($hours,$mins,$secs) = explode(':',$l2['jQuery']['length']); // Split into H:m:s
      $totalTimeSecs += (int) ltrim($secs,'0'); // Add seconds to total
      $totalTimeSecs += ((int) ltrim($mins,'0')) * 60; // Add minutes to total
      $totalTimeSecs += ((int) ltrim($hours,'0')) * 3600; // Add hours to total
    }
  }
}
echo "Total seconds: $totalTimeSecs<br />\n";

$hours = str_pad(floor($totalTimeSecs / 3600),2,'0',STR_PAD_LEFT);
$mins = str_pad(floor(($totalTimeSecs % 3600) / 60),2,'0',STR_PAD_LEFT);
$secs = str_pad($totalTimeSecs % 60,2,'0',STR_PAD_LEFT);
echo "Total time string: $hours:$mins:$secs";

See it working

solved how to sum the array time [closed]