Hi guys, its nice meeting you all, forgive me i might be asking simple questions believe me im totaly new to PHP and im so lost. Help me out with this.

Create an array with random number of elements and each value and each value is random itself. Display array content.

This is what i have tried:

$numbers = 10;

$data = range(1, 10);
$random = array_rand($data,$numbers);

for($i=0; $i<$numbers; $i++)
	print $random[$i];


it works but how do i create an array to answer this:
thank u in advance!!!!!!!!!!!!!
please drop me an email at [snipped]

Edited by Ezzaral: Added code tags and snipped email. Keep it on site and organized.

8 Years
Discussion Span
Last Post by JuliaNell


$ArrayLength = rand(0,100);//The array will be between 0 and 100 entries
$i = 0;//Incremental
$RandArray = array();
while ( $i <= $ArrayLength ) {//Until the array length is reached
     $RandArray[$i] = rand(1,100);//Set a value between 1 and 100
     $i++;//Add to the increment
echo "<pre>";//Create an output for plain text
print_r($RandArray);//Print out the array with formatting
echo "</pre>";//Close output

Is that what you needed?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.