EdwardJ Posted October 29, 2008 Share Posted October 29, 2008 hi, im a complete noob, so please dont be annoyed if this is too obvious. im trying to get a very big array (say 100 positions) with each one calling rand() function. So far Ive come up with this, but it doesnt work. i think it goes to an infinite loop $rand_array=array(); for ($i=0; $i=100; $i++){ $rand_array[$i]=rand(); echo $rand_array[$i]; } Link to comment https://forums.phpfreaks.com/topic/130644-big-array-question/ Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 yes it does. what you meant to do is: for ($i=0; $i<100; $i++){ Link to comment https://forums.phpfreaks.com/topic/130644-big-array-question/#findComment-677892 Share on other sites More sharing options...
EdwardJ Posted October 29, 2008 Author Share Posted October 29, 2008 youre right it does work sorry, i must have changed something when retyping it here Link to comment https://forums.phpfreaks.com/topic/130644-big-array-question/#findComment-677896 Share on other sites More sharing options...
DarkWater Posted October 29, 2008 Share Posted October 29, 2008 <?php $f = array_fill(0, 100, ''); $f = array_map(create_function('', 'return rand();'), $f); print_r($f); ?> I'd personally have used something like that. Link to comment https://forums.phpfreaks.com/topic/130644-big-array-question/#findComment-677909 Share on other sites More sharing options...
Barand Posted October 30, 2008 Share Posted October 30, 2008 Why, when it takes 2-3 times longer? Link to comment https://forums.phpfreaks.com/topic/130644-big-array-question/#findComment-678083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.