note 73810 deleted from function.mt-rand by mazzanet

From: Date: Mon, 12 Mar 2007 07:11:41 +0000
Subject: note 73810 deleted from function.mt-rand by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124361@lists.php.net to get a copy of this message
Note Submitter: bjoern dot lange at cd-dash dot com ---- In one of my forums was a discussion about, how to change an image randomly, so i wrote this code using mt_rand .... I hope you can use it .... <?php //ImageChange.php error_reporting(0);//hide the notice for the missing $iRand $sPath2ImageDir = Path;//preventing redundancy $aImages = scandir($sBildOrdnerPfad);//Dir 2 Array $iImageCount = count($aImages);//preventing redundancy while (getimagesize("{sPath2ImageDir}/{$aImages[$iRand]}")) {//recursion to get an image $iRand = mt_rand(2, $iImageCount-1);//min = 2 because $aImages[0] = "." and $aImages[1] = ".." echo "<img alt=\"Image{$iRand}\" src=\"{sPath2ImageDir}/{$aImages[$iRand]}\" title=\"Image{$iRand}\" />";//show the image unset($aImages, $iImageCount, $iRand, $sBildOrdnerPfad);//if this script is used in another script ?>

« previous php.notes (#124361) next »