Re: using print instead of echo
| From: | Pekka Saarinen | Date: | Sat, 07 Sep 2002 16:40:22 +0000 |
| Subject: | Re: using print instead of echo | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115612@lists.php.net to get a copy of this message | ||
At 9/7/2002, you wrote:
the example I have below.. I'm able to get working using the 'echo' command. But I would like to know how to format the same using the 'print' command. I am familiar with both. but with this one instance I am not sure how to format the print command correctly to get the same results as the echo command. Any suggestions would be appreciated.Hi, I don't get it, it works identically with echo and with print, doesn't it?$variable1[0]="one"; $variable2[0]="two"; $variable3[0]="three"; $variable4[0]="four";$j=1; while($j<5){ echo ${"variable"."$j"}[0]; $j++; }
$variable1[0]="one";
$variable2[0]="two";
$variable3[0]="three";
$variable4[0]="four";
$j=1;
while($j<5){
print ${"variable"."$j"}[0];
$j++;
}
If you get kicks from odd coding styles you might also use eval :)
$variable1[0]="one";
$variable2[0]="two";
$variable3[0]="three";
$variable4[0]="four";
$j=1;
while($j<5){
eval("print \"\$variable" . $j . "[0]<br>\";");
$j++;
}
-------------------------
Pekka Saarinen
http://photography-on-the.net
-------------------------