Tuck Posted October 11, 2009 Share Posted October 11, 2009 for ($i=0;$i<100;$i++) { $random = rand(0, 10); $slot[] = $random; } $RAN_1 = rand(0, 100); $RAN_2 = rand(0, 100); $RNUM_1 = $slot[RAN_2]; $RNUM_2 = $slot[RAN_1]; returns 0 and 0 Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 11, 2009 Share Posted October 11, 2009 You already have an existing thread for this. Don't start another one. Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935078 Share on other sites More sharing options...
Tuck Posted October 11, 2009 Author Share Posted October 11, 2009 i saw the math sub forum afterwords sorry :/ Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935079 Share on other sites More sharing options...
PFMaBiSmAd Posted October 11, 2009 Share Posted October 11, 2009 Your problem with it not working, it not a math problem. Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935083 Share on other sites More sharing options...
Tuck Posted October 11, 2009 Author Share Posted October 11, 2009 Your problem with it not working, it not a math problem. how should i know.. i'm asking for help and u just say its nothing to do with "math" now theres only 2 million other possibility's? Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935086 Share on other sites More sharing options...
Daniel0 Posted October 11, 2009 Share Posted October 11, 2009 It should be $slot[$RAN_2], etc. You might want to read up on PHP's syntax. Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935094 Share on other sites More sharing options...
PFMaBiSmAd Posted October 11, 2009 Share Posted October 11, 2009 You are also going to find that since $slot[100] does not exist, that you will randomly get a null value out when rand(0, 100) gives a 100. Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935097 Share on other sites More sharing options...
Amtran Posted October 12, 2009 Share Posted October 12, 2009 So...what does this actually do? Why do you need an array filled with random numbers from 1 to 10? Why not just echo rand(1, 10)? Quote Link to comment https://forums.phpfreaks.com/topic/177348-randoming-btw-101-random-integers/#findComment-935635 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.