0

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

enter image description here

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

WiiLF
  • 304
  • 3
  • 11
  • 1
    It is unclear what you actually ask. Please invest some time into revising your question. There is an "edit" link below it, _use it ..._ So you computed your stacked progress bar. Now what is it you then want to do? What is your actual problem now? What does "I want to see variable progress ..." mean? When, how, why? And what is "How can I show variable width (and not just leading smaller to the last)?" meant to express? – arkascha Nov 11 '22 at 11:04
  • I believe [this is what you may be needing](https://stackoverflow.com/questions/18628038/break-long-word-with-css) – Martin Nov 11 '22 at 11:26
  • Breaking down the post wont do any good. I mind as well build on the solution. I got the desired effect by modifying my formula. – WiiLF Nov 11 '22 at 18:06

0 Answers0