$numbering = ($arr[0]+$arr[1]+$arr[2]);
$red = ($arr[0]*100)/$numbering;
$r1[]=round($red,4);
$red2 = ($arr[1]*100)/$numbering;
$r2[]=round($red2,4);
$red3 = ($arr[2]*100)/$numbering;
$r3[] = round($red3,4);
$rx1=($r1[0]*10);
$rx2=($r2[0]*10);
$rx3=($r3[0]*10);
if(max($rx1,$rx2,$rx3)>600){
$max_value = 600;
}else{
$max_value = 'none';
}
//$rx1 = (($arr[0]==0) ? $r1[0]+0 : $r1[0]*10);
echo "Siedzi: ".$arr[0]."<div style=\"background:yellow;height:20px;width:{$rx1}px;max-width:{$max_value}px\"></div>";
echo "Kuca: ".$arr[1]."<div style=\"background:yellow;height:20px;width:{$rx2}px;max-width:{$max_value}px\"></div>";
echo "Patrzy: ".$arr[2]."<div style=\"background:yellow;height:20px;width:{$rx3}px;max-width:{$max_value}px\"></div>";
}
Skopiowane z: https://forum.pasja-informatyki.pl/255203/sonda-php-dzialanie-na-plikach#c255295 mój ostatni komentarz (kod).