kk instead of
k for iterator variables is preferable.
Even better are descriptive names, where possible. Often, that
$i variable could just as well be called
$blogpostIterator. We’re not in the age of floppy disks 💾 anymore, no need to shave off bytes by sacrificing code readability, unless you’re playing StackExchange Code Golf.
But sometimes, an iterator really is just an iterator, and sometimes they even need to be nested. Turns out simply using
ii instead of
i makes some things a tiny bit easier with just minimal (1 keystroke) extra effort.
Look at what happens when I select the
i variable in this real-world example:
And look at what happens when I use
Easier on the eyes, isn’t it?