-1

I have table that contain data

<td><?php echo $users->aa_0?></td
<td><?php echo $users->aa_1?></td>
<td><?php echo $users->aa_2?></td>
<td><?php echo $users->aa_3?></td>

when i'm applying static value to above code, it is working But when i'm changing it to dynamic the below code is not working... kindly help me

<?php foreach ($get_users as $users) { ?>
    <tr>
        <td><?php echo $users->aa_.$i?></td>
        <?php  ?>
    </tr>
<?php } ?>
Julian Schmuckli
  • 3,681
  • 11
  • 37
  • 64
clio
  • 1
  • 1
  • 3
    Possible duplicate of [Dynamic variable names in PHP](https://stackoverflow.com/questions/9257505/dynamic-variable-names-in-php) – JJJ Sep 21 '17 at 08:05
  • 1
    Although this looks like a perfect use case for arrays. – JJJ Sep 21 '17 at 08:05
  • 1
    Possible duplicate of [PHP - Concatenating two variables](https://stackoverflow.com/questions/7648688/php-concatenating-two-variables) – S4NDM4N Sep 21 '17 at 08:07

1 Answers1

0

Basically

$users->{"aa_$i"}

But as JJ said, you should use arrays, like

$users->aa[$i]

13DaGGeR
  • 147
  • 1
  • 10