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

Functions, Part I Forum

View Course » View Exercise

267 points
Ee83e984cdecd101d96c794ffef595ec?s=140&d=retro
Submitted by
rough93
over 2 years ago

8/8 Functions Show What You Know

Having a problem, won't accept the following code, returns whether or not I have used array(),

<?php
// Create an array and push on the names
// of your closest family and friends
$list = array();

arraypush($list, "Mason");
array
push($list, "Tommy");
arraypush($list, "Jeff");
array
push($list, "Irene");
array_push($list, "Leah");
// Sort the list
sort($list);
// Randomly select a winner!
$winner = $list[rand(0, count($list) -1)];
// Print the winner's name in ALL CAPS
print strtoupper($winner);
?>

I don't see the problem


2 votes

permalink

Hi,

Here is a solution for you.

<?php

$names = array();



array_push($names, "simona");
array_push($names, "valentina");
array_push($names, "kelly");
array_push($names, "laura");
array_push($names, "humphrey");

// Sort the list

sort($names);

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

print strtoupper($winner);
?>

Kelly :)

666 points
52ea8e838c1ccc0223000550_380258057
Submitted by
Kelly Nosakhare
over 2 years ago

1 Comment

Ee83e984cdecd101d96c794ffef595ec?s=140&d=retro rough93 over 2 years ago

Thanks!


0 votes

permalink

Thank you sooo much!

267 points
0b36eb17aaba755958107feff760b7b0?s=140&d=retro
Submitted by
Cricket777
over 2 years ago

1 Comment

558a7f2993767678fc000139_715775644 Ching Weng Keong over 2 years ago

Kelly, I tried the above codes and although the winner's name is clearly printed to the screen it won't let me pass. It keeps saying "Oops, try again. Remember to print out the name of the lucky winner!"