Bonjour à tous !
J'ai un souci "aléatoire". En effet, sur mon site j'affiche dans mon cadre droit des photos miniatures aléatoires issues d'un dossier spécifique.
De temps en temps, aucune photo ne s'affiche et j'ai cette erreur qui ressort : Notice: Undefined offset: 8 in C:\wamp64\www\mon_site\includes\cadre_droit.php on line 33
Voici le code en question :
Merci à vous si vous pouvez me venir en aide !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <?php $thumb_path = './images/cadre_droit/'; // Dossier des miniatures $list_ext = array('jpeg', 'jpg', 'JPG'); // Liste des extensions autorisées $folder = opendir($thumb_path); while($file = readdir($folder)){ $ext = explode('.', $file); $ext = strtolower($ext[count($ext) -1]); if (in_array($ext,$list_ext)){ $list_thumbs[] = $thumb_path . $file; } } $i= count($list_thumbs); srand((double)microtime()*1000000); $affimage=rand(1,$i); LA FAMEUSE LIGNE 33 => echo '<center><table class="arrondi_tableau_epais" width="160" height="120"><tr><td align="center"><img src='.$list_thumbs[$affimage].' title="photo aléatoire"/></td></tr></table></center>'; ?>
Partager