Simple image rotation with PHP


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /Add before <html> tags
  2. //Script
  3. if ($_COOKIE[\'head\'] != \"\") {
  4. $ausgabe = $_COOKIE[\'head\'];
  5. }
  6. else {
  7. $bilder = array(\"bild1\", \"bild2\", \"bild3\");
  8. $ausgabe = $bilder[rand(0,2)];
  9. setcookie (\"head\", $ausgabe, time()+1000);
  10. }
  11.  
  12.  
  13. //Output
  14. $sufix = \".jpg\";
  15. $dir = \"http://localhost/weblog/covers/\";
  16. if (isset($_COOKIE[head])) {
  17. echo \'<img src=\"\'.$dir.$ausgabe.$sufix.\'\" alt=\"Cover\" />\';
  18. }
  19. else {
  20. echo \'<img src=\"http://localhost/weblog/alt.jpg\" />\';
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.