0

this is sample foreach in codeigniter

<select>
<?php
    $no = 0;
    foreach($value as $v){
?>
<option value=<?=$v->id?>><?=$v->name." -- ".$buy[$no]->currency;?></option>
<?php 
    $no++;
} ?>

this is sample code in smarty

<select>
   {foreach from="$value" item="v"}
       <option value="{$v.id}" >"{$v.name} -- $buy[0].currency"</option>
   {/foreach}
</select>

i want $buy like this
$buy[0]
$buy[1]
$buy[3]
etc...

Arif Hidayat
  • 67
  • 1
  • 9
  • See here http://stackoverflow.com/questions/8674831/how-do-you-increment-an-assigned-variable-in-smarty-without-displaying-it what you want has nothing to do with foreach, you basically want to increment a variable. – Mihai P. Mar 13 '15 at 03:24
  • Hi.. Mihai. i want to increment $buy[0], $buy[1] like this $buy[$no] – Arif Hidayat Mar 13 '15 at 03:38
  • 1
    I am not sure i understood then, I thought you want to do something like {assign var=no value=0} then use {$buy.$no} then {inc var=no} so it increases. – Mihai P. Mar 13 '15 at 03:45

0 Answers0