radons Posted March 30, 2006 Share Posted March 30, 2006 Hi, i was hoping someone could help me out...I want to make a random image displayer that displays an random image.. That's not the problem though, the problem is that i want to give all the images have a pick chance. It will only show one image and must always show one.So, one image has a pick chance of 40%, the other of 70% and so on.I have no idea how to do this, thanks for your help =) Quote Link to comment https://forums.phpfreaks.com/topic/6185-random-image/ Share on other sites More sharing options...
shocker-z Posted March 30, 2006 Share Posted March 30, 2006 i think u ment 40% and 60% otherwiseit would be over 100% but heres a lil sumet that will work[code]<?php$images=file('randimages.txt');$count=count($images);$random=rand(0,$count);echo $images[$random];?>[/code]and then in the file randimages.txt put 6 of the image you want at 60% and 4 of the image name that you want to be 40% seporate by line..like this:image60.jpgimage40.jpgimage60.jpgimage60.jpgimage40.jpgimage40.jpgimage60.jpgimage40.jpgimage60.jpgimage60.jpgand then use $images[$random] to display the image name inside the image tags.. Quote Link to comment https://forums.phpfreaks.com/topic/6185-random-image/#findComment-22348 Share on other sites More sharing options...
radons Posted March 30, 2006 Author Share Posted March 30, 2006 Thanks for the reply.But an example of what i have now:All images are stored in the database,ID LINK CHANCE1 image1.jpg 40%2 image2.jpg 50%3 image3.jpg 10%I want it to pick one and the ones with a higher chance well get picked faster.Also, i'm working on another system that shows random images. Which all have their own chance to be showed, but it is random if it will show up or not. ID LINK CHANCE (to be shown)1 image1.jpg 40%2 image2.jpg 50%3 image3.jpg 60%4 image4.jpg 70%5 image5.jpg 30%Think about an RPG with an item drop system, something like that here. Quote Link to comment https://forums.phpfreaks.com/topic/6185-random-image/#findComment-22354 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.