Math functions II


#1

Hi, i am stuck here: PHP Math functions II.
here is my code

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

and the result is that after submitting it is always the same sentence:
Oops, try again. The random output you printed from your name should be a letter.

i have tried to change the browser, restart codecademy, nathing helped.

thank you som much :slight_smile: janka


#2

Try putting the random number in its own variable ,and then using the variable instead, like so...

    $num = rand(0, strlen($name)-1);
    print substr($name, $num, 1);

#3

Thanks a lot, now it works.. Jana