I have this loop:
<?php foreach ($option['option_value'] as $option_value) { ?>
<?php if ($option_value['quantity'] <= 0) { ?>
What code should be put here?
<?php } ?>
<?php } ?>
<?php echo $i; ?>
Let’s say the loop is 10 rounds. So, when $option_value[‘quantity’] <= 0 I need some variable to count it, and if the condition of $option_value[‘quantity’] <= 0 is met 3 times during those 10 rounds, I want the variable which counts that to have a value of 3, and echo it at the end. So, any help would be appreciated. I’ve tried something with i++ etc. but I don’t know how to define it in order to make it work and count if the condition is met.
Thanks in advance.
You want to initialize
$ioutside the scope of the foreach loop and then increment it each time the condition is true: