AdRock Posted March 25, 2010 Share Posted March 25, 2010 I am trying to make myself a dummy data generator to populate my database but i'm having trouble getting a random name out of the array. I am trying to create a 150 long list of random names from the array but all i get is a list of numbers which i presume are the key to each element. What I want is to data Any ideas how i can fix this? $firstnames = array("0" =>"JACK", "1" =>"OLIVER", "2" =>"THOMAS", "3" =>"HARRY", "4" =>"JOSHUA"); for($i=0; $i < 150; $i++) { $rand_firstname = array_rand($firstnames,1); $rand_firstname = ucwords($rand_firstname); print_r($rand_firstname); } Link to comment https://forums.phpfreaks.com/topic/196495-pick-a-random-array-element/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.