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

Functions, Part I Forum

View Course » View Exercise

443 points
5614d70586f552a49c000142_284904470
Submitted by
Orkut Mahmud
almost 2 years ago

Oops, try again. Your printed output from rand() should be an integer.

<?php
$name = "Orkut";
$length = strlen($name);

   $random = rand(0, $length-1); 

   echo substr($name, $random, 1);
?>

when I submit this code, I face this problem.


0 votes

permalink

I did this and it worked...:

$name = "my name";    
print substr($name, 0, rand(0,2));

688 points
Picture
Submitted by
Eryc da Silva
almost 2 years ago

1 Comment

Picture Stefan de Jong almost 2 years ago

Sadly doesn't work here either


0 votes

permalink

$name = "james";

print substr($name, 0, rand(0,4));

this worked for me....whether its right or not i've no idea....but i got the green light to advance.

768 points
513a6fad04f5d519d5001f3b_718214888
Submitted by
james
almost 2 years ago