I am making a solution that allows a multi incremented progressbar based on float values from a array.
I am trying to achieve this (progress illustration):
[1#####2###############3###########]
1, 2, 3 etc represents the float value (in this case, 3 floats are read from array and set as width in no specific order).
I wrote this
$i = 0;
echo '<div style="padding:5px;width:50px">';
$progress = array(99.9, 99.3, 85.9, 30.8, 30.8);
foreach ($progress as $perc) {
$i++;
$calc = count($progress) / $i * 100;
echo "<div style=\"display:inline-block;border:1px solid black;height:25px;width:$calc%\">$calc</div>";
}
echo '</div>';
Which produces this
Great, so that will work in a specified container width.
But, is the formula correct? I want to see variable progress within this container, as many keys as they are in the array.
How can I show variable width (and not just leading smaller to the last)?
Any help is appreciated