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

Functions, Part I Forum

View Course » View Exercise

381 points
B220593df06861d482bbb517241d40d5?s=140&d=retro
Submitted by
RadiumeSportsDeathstroke
almost 3 years ago

Why won't this work?

<?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]);
?>

Why is this code not working? It keeps saying "Remember to print out the name of the lucky winner" when it does print out the name.


0 votes

permalink

Don't see anything wrong with the code, even tried it out and it passed...

1426 points
541b5b0d282ae3a23e0008cf_298297838
Submitted by
beachViper
almost 3 years ago


0 votes

permalink

The code seems to work fine after you fix
arraypush($names, "Scottie");
arraypush($names, "Nathan");

to look more like this
array_push($names, "Scottie");
array_push($names, "Nathan");

598 points
525610c380ff33f3d7000bd7_946089858
Submitted by
Matt Camp
almost 3 years ago