Math Functions II


#1

How come this code does not pass the check?

It selects and prints only 1 character from my name variable.

Error Oops, try again. The random output you printed from your name should be just one character.



<html>
    <p>
    <?php
    // Use rand() to print a random number to the screen
    print rand (0,30);
    ?>
    
    
    <?php
    // Use your knowledge of strlen(), substr(), and rand() to
    // print a random character from your name to the screen.
    $name = 'Username';
    echo substr($name, rand (0, strlen ($name)-1), 1);
    ?>
    </p>
</html>



#2

Try giving each snippet its own paragraph…

?>
</p>

<p>
<?php 

#3

That did it! Thanks! Can’t believe I didnt see it.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.