###incrementing a counter variable inside a foreach
The foreach
statement has two syntaxes"two syntaxes"1 and because the array indexes of $thumbWidths
are numeric, the second one can be used to have the value of $i
updated automatically (i.e. to have each numeric index assigned , starting at 0), reducing the initial assignment of the counter variable (i.e. $i = 0;
) and updating the counter value at the end of each block (i.e. $i++;
).