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

Functions, Part I Forum

View Course » View Exercise

58 points
Picture
Submitted by
Mustafa Alshawi
about 3 years ago

my code is not working it giving me an error massage ???

<?php
print rand(1, 100);//Everything what we must do to
//solve this, is ONLY INSERT 'PRINT' to
//this place!!!

//And the rest of code is unchanged:
?>
</p>
<p>
<?php    
$name = "Mustafa";
$namelength = strlen($name);

rand(0, $namelength -1) ;
?>
</p>

5 votes

permalink

It's always nice to get a good, relaxing massage

1789 points
54af92ace39efe92a4000925_582117280
Submitted by
jablanko
about 3 years ago

1 Comment

1cd44f6b22536d9ffeedafda1fa3f056?s=140&d=retro yassin1999 about 3 years ago

NO


1 vote

permalink

$name = "David";
$length = strlen($name);
print substr($name, rand(0,$length -1),1);

you are generating a random number from 0 to $namelength -1, you need to print a character from your name.

1099 points
Picture
Submitted by
Dave Michael
about 3 years ago