fork download
  1. <?php
  2.  
  3. $percentual_total="";
  4. $array = array('4.75', '1.5', '0.75');
  5.  
  6. $total = '7.0';
  7.  
  8.  
  9.  
  10. foreach ($array as $tem => $key) {
  11.  
  12. $percentual = round(($key / $total) * 100);
  13.  
  14. $percentual_total .= "Tempo: " . $key . ", Percentual: " . $percentual . "\n";
  15. }
  16.  
  17. echo $percentual_total;
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
Tempo: 4.75, Percentual: 68
Tempo: 1.5, Percentual: 21
Tempo: 0.75, Percentual: 11