Trouble displaying random images on my front page.
The front page is “index.php”.
I am trying to adorn my front page with randomly selected images.
The images are listed in a text file: “actresses.txt”.
The images are jpg and are stored in the folder “actresses”.
What is supposed to happen is the image is replaced each time the page is refreshed.
The first code block should make the selection and then draw the image.
But it does not happen … Must be a syntax confusion.
The sequence should go thus …
1 Load the list into $pix
2 Make a random number from 1 to 779
3 Assign it to $i
4 Find the image title in the $i position in the list
5 Load the image from the actresses’ folder
6 Display it
[php]
<?php $pix=file("actresses.txt"); mt_srand(); $i=mt_rand (1,779); $pic=$pix[$i]; echo '[/php]
The second block adds the title of the image.
This block, happily, does work.
[php]<?php
$x=strlen($pic)-9;
$tit=substr($pic,0,$x);
echo $tit;
?>[/php]
Thank you for your kind attention