Posted By

deadpixel on 05/13/08


Tagged

html favicon


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

basicmagic
robksawyer
m4tik


random favicon


 / Published in: PHP
 

selects a random favicon from a specified directory. copy and paste it into the html head tag and change the dir variable to your icons directory.

  1. <?php
  2. $dir = "images/icons/";
  3. $files = array();
  4. if ($handle = opendir($dir)) {
  5. while (false !== ($file = readdir($handle))) {
  6. $files[] = $file;
  7. }
  8. }
  9. $icon = $files[rand(2,count($files)-1)];
  10. echo "<LINK REL=\"SHORTCUT ICON\" HREF=\"/images/icons/" . $icon . "\">";
  11. ?>

Report this snippet  

You need to login to post a comment.