tags:

views:

34

answers:

1
 <?php for ($i=1; $i<=(count($img_array))/4; $i++): ?> 
 <input type="hidden" id="img{$i}_name" value="<?php echo ${'image_src'.$i};?>" />
 <?php endfor;?>

In the output, the 'id' is exactly as the code, ie: img{$i}_name, but I want the $i to be replaced offcourse, by its value...

Syntax error probably, any ideas how to write it?

PS: The value works!

+2  A: 
 <?php for ($i=1; $i<=(count($img_array))/4; $i++): ?> 
 <input type="hidden" id="img<?php echo $i; ?>_name" value="<?php echo ${'image_src'.$i};?>" />
 <?php endfor;?>

You're outputting the $i variable outside of the php tags so the interpreter never outputs it.

Mike B