I am trying to build up a script that gets the current percentage of the iteration of a loop.
I have :
Store the total length of the array in a variable and use that to calculate the percentage. Watch that you prefix your variables with $
. Also, you might want to name your variables more appropriately—an array isn't a key.
$counter = 0;
$length = count($array);
foreach ($array as $value) {
$counter++;
$percentage = $counter / $length;
}