Posted by David Haynes on 11/10/81 11:45
Garry Jones wrote:
> I am trying to change a value but cant quite grasp the syntax
> <?
> $vtfa=test
> $dn=1
> ?>
>
> <td><?= $vtfa.$dn ?></td>
>
> <? $dn = $dn + 1 ?>
> <td><?= $vtfa.$dn ?></td>
> <? $dn = $dn + 1 ?>
> <td><?= $vtfa.$dn ?></td>
>
> What I want are the three cells to consist of test1, test2 and test3. As you
>
> Any help appreciated
>
> Garry Jones
> Sweden
>
>
Brute force:
<?php
$vtfa = 'test';
$dn = 1;
?>
<td><?php echo $vtfa.$dn;$dn++;?></td>
<td><?php echo $vtfa.$dn;$dn++;?></td>
<td><?php echo $vtfa.$dn;$dn++;?></td>
Slightly more elegant:
<?php
$vtfa = 'test';
for($dn=1; $dn < 4; $dn++) {
printf("<td>%s%d</td>\n", $vtfa, $dn);
}
-david-
[Back to original message]
|