PC Nerd Posted March 17, 2007 Share Posted March 17, 2007 seems simple enough, but not as much as rand($ARRAY); how would i select a random element from an array??? ie $User_Prize = rand($Users); thanks Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/ Share on other sites More sharing options...
ShogunWarrior Posted March 17, 2007 Share Posted March 17, 2007 array_rand Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/#findComment-209648 Share on other sites More sharing options...
PC Nerd Posted March 17, 2007 Author Share Posted March 17, 2007 i assume that goes like $VARIABLE = array_rand($ARRAY); Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/#findComment-209650 Share on other sites More sharing options...
kenrbnsn Posted March 17, 2007 Share Posted March 17, 2007 Why don't you read the entry in the manual for the function? Ken Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/#findComment-209653 Share on other sites More sharing options...
PC Nerd Posted March 17, 2007 Author Share Posted March 17, 2007 is it so hard to just say yes or no...... and if no then referense the manual, becauase it doesnt always explain very well. Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/#findComment-209658 Share on other sites More sharing options...
AndyB Posted March 18, 2007 Share Posted March 18, 2007 is it so hard to just say yes or no...... and if no then referense the manual, becauase it doesnt always explain very well. You'll learn more if you look in the manual. Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/#findComment-209705 Share on other sites More sharing options...
chawezul Posted March 18, 2007 Share Posted March 18, 2007 $array[mt_rand(0,count($array))]; Link to comment https://forums.phpfreaks.com/topic/43178-solved-random-element-from-an-array/#findComment-209708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.