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

Functions, Part I Forum

View Course » View Exercise

1016 points
517b841a81cb7e1df9002c57_966681090
Submitted by
Magnus Vestergaard
over 2 years ago

A solution that works xD

Hey guys,

<?php
$names = array();
arraypush($names, "Scottie");
array
push($names, "Nathan");
array_push($names, "Griffin");
sort($names);
$random = rand(0,count($names) -1);
print "".strtoupper($names[$random])."";
?>

I had some troubles but that codes works!
Note: It's needed to put a p (paragraph) tag around the output when you print! :)

Magn0053


0 votes

permalink

Hello,

a bit late I know ^^
Show us your code maybe?

Or sometimes, the reason is that codecademy is really buggy :(
Try refreshing your page with "ctrl+f5" (it purges the cache for that page).
(and just in case, copy your code before you do that ^^)

I hope that helped.

888 points
Ebd6d300a6cfb3bdd5c7f29e3b9bd83c?s=140&d=retro
Submitted by
Jérôme
over 2 years ago

3 Comments

517b841a81cb7e1df9002c57_966681090 Magnus Vestergaard over 2 years ago

I've updated with the code now :)

517b841a81cb7e1df9002c57_966681090 Magnus Vestergaard over 2 years ago

I fixed it, when i printed the output with around it worked! xD

54b526fc95e37880d5002652_10208156 aagoldfein over 2 years ago

You also need to add the underscores into "arraypush"
If you don't get that then just use this:
<?php
$names = array();
array
push($names, "Scottie");
arraypush($names, "Nathan");
array
push($names, "Griffin");
sort($names);
$random = rand(0,count($names) -1);
print "".strtoupper($names[$random])."";
?>