Random logo script not working ?
-
Hello,
I would like to display a random logo from a specific folder. I’ve found the following script, it’s perfectly working on a test.php located in my folder theme but nothing is displaying when I put the code in header.
Here’s the code :
<?php // Ouvre un dossier bien connu, et liste tous les fichiers $directory = 'images/logo'; // Définition d'$image comme tableau $image = array(); //on vérifie s’il s’agit bien d’un répertoire if (is_dir($directory)) { //on ouvre le repertoire if ($dh = opendir($directory)) { //Lit une entrée du dossier et readdir retourne le nom du fichier while (($file = readdir($dh)) !== false) { // Vérifie de ne pas prendre en compte les dossier ... if ($file != '...' && $file != '..' && $file != '.') { // On ajoute le nom du fichier dans le tableau $image[] = $file; } } //On ferme le repertoire closedir($dh); // On récupère le nombre d'image total $total = count($image)-1; // On prend une valeur au hasard entre 1 et le nombre total d'images $aleatoire = rand(0, $total); // On récupère le nom de l'image avec le chiffre hasard $image_afficher = "$image[$aleatoire]"; // Affiche l'image du hasard :p print "<img src='$directory/$image_afficher' border='0'>"; } } ?>
Is there a part of this code incompatible with WordPress ?
Thanks you for your help.
Best regards,
Viewing 13 replies - 1 through 13 (of 13 total)
Viewing 13 replies - 1 through 13 (of 13 total)
- The topic ‘Random logo script not working ?’ is closed to new replies.