<?php
$percentual_total="";
$array = array('04:45', '01:30', '00:45');
$total = '07:00';
$explodeHoraTotal = explode(":",$total); //retorna um array onde cada elemento é separado por ":" $minutosTotal = $explodeHoraTotal[0];
$minutosTotal = $minutosTotal*60;
$total =$minutosTotal+$explodeHoraTotal[1];
foreach ($array as $tem => $key) {
$quebraHora = explode(":",$key); //retorna um array onde cada elemento é separado por ":" $minutos = $quebraHora[0];
$minutos = $minutos*60;
$tot =$minutos+$quebraHora[1];
$percentual = round(($tot / $total) * 100);
$percentual_total .= "Tempo: " . $key . ", Percentual: " . $percentual . "\n";
}
echo $percentual_total;
PD9waHAKCgkkcGVyY2VudHVhbF90b3RhbD0iIjsKCSRhcnJheSA9IGFycmF5KCcwNDo0NScsICcwMTozMCcsICcwMDo0NScpOwoJCgkkdG90YWwgPSAnMDc6MDAnOwoJJGV4cGxvZGVIb3JhVG90YWwgPSBleHBsb2RlKCI6IiwkdG90YWwpOyAvL3JldG9ybmEgdW0gYXJyYXkgb25kZSBjYWRhIGVsZW1lbnRvIMOpIHNlcGFyYWRvIHBvciAiOiIKCSRtaW51dG9zVG90YWwgPSAkZXhwbG9kZUhvcmFUb3RhbFswXTsKCSRtaW51dG9zVG90YWwgPSAkbWludXRvc1RvdGFsKjYwOwoJJHRvdGFsID0kbWludXRvc1RvdGFsKyRleHBsb2RlSG9yYVRvdGFsWzFdOwoJCgkKCQoJICAgICAgZm9yZWFjaCAoJGFycmF5IGFzICR0ZW0gPT4gJGtleSkgewoJICAgICAgCgkgICAgICAkcXVlYnJhSG9yYSA9IGV4cGxvZGUoIjoiLCRrZXkpOyAvL3JldG9ybmEgdW0gYXJyYXkgb25kZSBjYWRhIGVsZW1lbnRvIMOpIHNlcGFyYWRvIHBvciAiOiIKCQkgICRtaW51dG9zID0gJHF1ZWJyYUhvcmFbMF07CgkJICAkbWludXRvcyA9ICRtaW51dG9zKjYwOwoJCSAgJHRvdCA9JG1pbnV0b3MrJHF1ZWJyYUhvcmFbMV07CgkKCSAgICAgICRwZXJjZW50dWFsID0gcm91bmQoKCR0b3QgLyAkdG90YWwpICogMTAwKTsKCQoJICAgICAgJHBlcmNlbnR1YWxfdG90YWwgLj0gIlRlbXBvOiAiIC4gJGtleSAuICIsIFBlcmNlbnR1YWw6ICIgLiAkcGVyY2VudHVhbCAuICJcbiI7Cgl9CgkKCSBlY2hvICRwZXJjZW50dWFsX3RvdGFsOw==