Count the percentage of the number of the current iteration in a foreach loop

后端 未结 5 2017
别那么骄傲
别那么骄傲 2021-01-29 07:59

I am trying to build up a script that gets the current percentage of the iteration of a loop.

I have :



        
5条回答
  •  借酒劲吻你
    2021-01-29 08:22

    Firstly, you have to get the total amount of iterations. count() helps in this case.

    Live example

    Converting 0.xx to x % is left as an exercise for the reader.

提交回复
热议问题