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

Functions, Part I Forum

View Course » View Exercise

443 points
Submitted by
Orkut Mahmud
over 2 years ago

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

$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


I did this and it worked...:

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

688 points
Submitted by
Eryc da Silva
over 2 years ago

1 Comment

Picture Stefan de Jong over 2 years ago

Sadly doesn't work here either

0 votes


$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.

772 points
Submitted by
over 2 years ago