Sorry if this seems like a stupid question. I'm a beginner and I'm not sure what to do
I have 5 images from 1-4.png and 5.jpg (5 images in total, 4 pngs and 1 jpg)
I want to show a random image so I generate a number from 1-5 using
this is where I'm stuck
How do I add the .jpg or .png file extension after $random without it creating an error
basically I want it to do this
if random.png exists echo random.png else echo random.jpg
thanks and I hope you understand me
I have 5 images from 1-4.png and 5.jpg (5 images in total, 4 pngs and 1 jpg)
I want to show a random image so I generate a number from 1-5 using
PHP:
$random=rand(1,5)
PHP:
if (file_exists($random)) {
How do I add the .jpg or .png file extension after $random without it creating an error
basically I want it to do this
if random.png exists echo random.png else echo random.jpg
thanks and I hope you understand me





