Reply to Re: happy new year with a simpleton question...

Your name:

Reply:


Posted by jukka on 01/01/06 15:37

> [code]
> <?php
> $picture_array = array("car.jpg","cat.gif","cow.png");
> $rand_no = rand(0,3);
> echo "<img src=\"".$picture_array[$rand_no]."\" />";
> ?>
> [/code]

> <?php
> $picture_array = glob("*.*");
> $rand_no = rand(0,"count($picture_array)");
> echo "<img src=\"".$picture_array[$rand_no]."\" />";
> ?>

Correct me if I'm wrong, but shouldn't it be $rand_no - 1? Since three
pictures would be 0,1,2 and if the random number is between 0-3 it could
be 3, which is not in our array.

[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

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