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

Functions, Part I Forum

View Course

397 points
Picture
Submitted by
AmethystFae
about 2 years ago

So frustrated. 5/8

I actually GET a random character using this code. It still will not allow me to pass the lesson. What am I doing wrong?

<?php
print rand();
?>

<?php
$name = "Kelsey";
print substr($name, rand(0, strlen($name))-1, 1);
?>


0 votes

permalink

You have one extra bracket after strlen($name). The following code works:
echo substr($name, rand(0,strlen($name)-1), 1);
Just move that bracket after "-1".

1197 points
5625421e9113cb79bf0001dd_208035150
Submitted by
Y1G9D87
about 2 years ago