Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End FOR loop with counter in variables Re: FOR loop with counter in variables

#135780
Alen
Participant

You can also be explicit by using `{}` like so:

for( $i=1; $i<4; $i++ ) {
if( get_field( “product_image_{$i}” ) ) {
echo get_field( “product_image_{$i}” ); } }

This way when you’re reading PHP code, it’s clear what is happening or what is expected to happen.