Freid001 Posted December 13, 2011 Share Posted December 13, 2011 Hi! Ok so I have a array inside a for loop. In the loop 1 is added to the array number and a value is stored in each new array number when the loop is run. EXAMPLE: (LOOP runs 1st time), array [0] = $value; , (LOOP runs 2nd time), array [1] = $value; (LOOP run 3rd time), array [2] = $value; (AND SO ON) I am then outside of the for loop taking the max number of the array and generating a random number with in the max array number. EXAMPLE: $rand = rand(0, $max_array_number); Next I want to echo out the value of the array number which rand has selected. EXAMPLE: echo array[$rand]; However when I echo this I just get the message array. No the value which is store in it ??? What does this mean? Please help. Thanks Link to comment https://forums.phpfreaks.com/topic/253109-php-array-please-help-d/ Share on other sites More sharing options...
Freid001 Posted December 13, 2011 Author Share Posted December 13, 2011 Don't worry I think I have fixed it Thanks any way Link to comment https://forums.phpfreaks.com/topic/253109-php-array-please-help-d/#findComment-1297595 Share on other sites More sharing options...
Pikachu2000 Posted December 13, 2011 Share Posted December 13, 2011 Did you forget the $ before the array name? If you're just adding an incremented number to an array, you can use range(). $min = 0; $max = 100; echo array_rand(range($min, $max)); Link to comment https://forums.phpfreaks.com/topic/253109-php-array-please-help-d/#findComment-1297596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.