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

Functions, Part I Forum

View Course » View Exercise

282 points
Submitted by
over 2 years ago

Why is this not working?

Hey everyone, I'm currently on Functions Part I in the php course and i'm stuck with this question.

Task: to create a variable containing my name (Done this) then use rand() function or substr()
to generate a random letter of my name but it's only printing a number.


rand($name= 0,2);

print $name;`

0 votes


Hi Umbriel,

$name = 'Sam';
$callname = substr($name, 0, 1); //the 1 is the letters across it goes, try 2 and 3.
print $callname;


 print $name[rand(1, strlen($name)-1)]; //random letter

287 points
Submitted by
George Hatzi
over 2 years ago