Home › Forums › Back End › FOR loop with counter in variables › Re: FOR loop with counter in variables
May 20, 2013 at 3:02 pm
#135747
Participant
> `the_field( ‘”product_image_’.$i.'”‘ );`
too many quotes.
If `get_field()` **returns** a value, or false if there is no value, then you can do like so:
for( $i=1; $i<4; $i++ ){
# note: double-quotes around whole string
$var = get_field( “product_image_$i” );
# assuming you want to output *now*
if( $var ){ echo $var; }
}