Random Images - since we have avatars

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

i had wondered how you guys were having random avatars. so i wrote my own code and then found this topic so i figured i'd post my code here too....

Code: Select all

<?
if($dir = opendir('avatar'))
&#123;
   while (false !== ($file = readdir($dir)))
   &#123;
      if ($file != "." && $file != ".." && $file != "main.php")
      &#123;
         $pictures&#1111;] = $file;
      &#125;
   &#125;
&#125;
closedir($dir);
$rand_avatar = array_rand($pictures);
$avatar_dir = "./avatar/";
include($avatar_dir.$pictures&#1111;$rand_avatar]);
?>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

i got one now too~

8)
Post Reply