For Loop in PHP

by Hiroshi on June 19, 2008

in Loops, Randomizing, Scripts

for loop

I am describing for loop with an example that include randomizing number display using images from a directory. Use following script and create a folder nb and put images 0.gif, 1.gif, … , 9.gif containing same digit over each and see.

PHP Code

$mynumber= rand(1111111111,9999999999);
// echo $mynumber;
for($i=0; $i<$ilength; $i++)
$ipic= substr($mynumber, $i, 1);
$sFilePath = "";
if (file_exists("nb/".$ipic.".gif"))
$sFilePath = "nb/".$ipic.".gif";
<img src="<?= $sFilePath ?>">

For Loop Rand Numbers Script Download

Related Posts

Previous post:

Next post: