MDanz Posted December 19, 2009 Share Posted December 19, 2009 i've got 3 images. i want only 1 to appear at random between these 3, how do i do that? Link to comment https://forums.phpfreaks.com/topic/185660-random-images/ Share on other sites More sharing options...
salathe Posted December 19, 2009 Share Posted December 19, 2009 Ask it nicely? More seriously, you need to give as much detail as possible for us to help you. There's no point in anyone spending any time writing a detailed response with code samples and other help if your specific case requirements aren't met. Link to comment https://forums.phpfreaks.com/topic/185660-random-images/#findComment-980350 Share on other sites More sharing options...
MDanz Posted December 19, 2009 Author Share Posted December 19, 2009 e.g. <img src="img 1.jpg"> <img src="img 2.jpg"> <img src="img 3.jpg"> i want to display only 1 of these at random, so either img 1, img 2 or img 3. Link to comment https://forums.phpfreaks.com/topic/185660-random-images/#findComment-980352 Share on other sites More sharing options...
abazoskib Posted December 19, 2009 Share Posted December 19, 2009 check out the rand() function. use it to generate a random number between 1 and 3 inclusively. Then once a random number is generated use <img src="img<?php echo $rand_number; ?>.jpg"> Link to comment https://forums.phpfreaks.com/topic/185660-random-images/#findComment-980353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.