This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Jacynth Agraan
about 9 years

Why doesn't this work?

<?php
$name = "Jacynth";
print substr($name, rand(0, strlen($name) - 1), 1);
?>

I keeps saying “Your printed output from rand() should be an integer.”

Answer 552209a9d3292f6414000436

1 vote

Permalink

if you’re talking about exercise 5/8, it’s because it’s asking for you to print a random number, then print a random number from your name.

you’re right, that code does work- you’ve just skipped step 1 of the exercise.

points
Submitted by David Fudge
about 9 years

Answer 55228edf86f5525653000223

0 votes

Permalink

points
about 9 years

1 comments

Jacynth Agraan about 9 years

You have to echo $rand in the first block of PHP