Reply to Re: Syntax to change value

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация