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

Functions, Part I Forum

View Course » View Exercise

349 points
2e25945f08e588affb060df00b863440?s=140&d=retro
Submitted by
Khan128
over 2 years ago

what is the problem? It said to print the lucky number . (error)

<?php
$names = array();

arraypush($names, "Khan");
array
push($names, "Ahad");
arraypush($names, "Ali");
array
push($names, "Omar");
array_push($names, "And");

// Sort the list

sort($names);

$winner=$names[rand(0,count($names)-1)];
echo strtoupper ($winner);

?>


0 votes

permalink

<?php
// Create an array and push on the names
// of your closest family and friends
$names= array();
arraypush($names,"Jim");
array
push($names,"Ken");
arraypush($names,"Jane");
array
push($names,"Mike");
array_push($names,"Nate");
// Sort the list
sort($names);
// Randomly select a winner!

$random= rand(0,count($names)-1);
// Print the winner's name in ALL CAPS
print strtoupper($names[$random]);

?>
</p>

this is what I put and I got it right you don't need your names var 2 times and with you barckets and parenthesis

847 points
57067220083510758e3589b2e4e493c6?s=140&d=retro
Submitted by
Nathaniel James
over 2 years ago


0 votes

permalink

thanxxxxxxxxxxxxxxxxxxxxxxxxx a lot

349 points
2e25945f08e588affb060df00b863440?s=140&d=retro
Submitted by
Khan128
over 2 years ago