Variable as part of other variable php -


this question has answer here:

i have script:

<?php for($i=1; $i<10; $i++):?> <?php if($this->item->nuotrauka{$i}):?> <div class="vobsmall"> <img src="<?php echo $this->item->nuotrauka{$i}; ?>"/> <?php echo $this->item->nuotrauka{$i}; ?> </div> <?php endif; ?> <?php endfor; ?> 

there's 9 variables $this->item->nuotrauka1, $this->item->nuotrauka2 etc.

as can see here i'm trying call these variables using {i} number of object variable. hovewer code above returns single char variable , not full variable want. how should write {i} here want ?

try this:

echo $this->item->{"nuotrauka".$i}; 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -