This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

293 points
8b3976467be5cde820fd1b908e2b7e3d?s=140&d=retro
Submitted by
muneebhtml
over 2 years ago

3rand() expects exactly 2 parameters, 1 given (line 27) M getting this error plz help

<?php
// Create an array and push on the names
// of your closest family and friends
$thearray = array();
array
push($thearray,"Muneeb");
array
push($thearray,"mano");
array
push($the_array,"azra");

// Sort the list
sort($the_array);
print count($the_array);





// Randomly select a winner!




// Print the winner's name in ALL CAPS
print rand($the_array);
?>
</p>

0 votes

permalink

If you want to print name in all caps then you don't have to use rand.
Assuming $winner is the variable declared for the randomly chosen name. This code is for showing name in all caps.

print strtoupper($the_array[$winner]);

For complete code, here is the solution.

    $the_array = array ();
array_push($the_array, "Muneeb");
array_push($the_array, "mano");
array_push($the_array, "azra");

$newcount = count($the_array) - 1;

// Sort the list
sort($the_array);
print join(", ", $the_array);
// Randomly select a winner!
$winner = rand(0, $newcount);

// Print the winner's name in ALL CAPS
print strtoupper($the_array[$winner]);

545 points
283e4cfe624216454c4940c1108e1605?s=140&d=retro
Submitted by
Hero0o
over 2 years ago