Math Functions II


#1


<html>
    <p>
    <?php
    print rand();
    
    ?>
    </p>
    <p>
    <?php
    $name = "AliAmaim";
    $num = rand(0,7);
    print substr($name, $num, $num);

    ?>
    </p>
</html>

What's wrong with this? it prints out more than one letter.


#2

why is there $num twice?


#3

Hey, this is the code that worked for me:

$name = 'Ashwin';
echo substr($name, rand(0, strlen($name) - 1), 1);

Hope this helped!


#5

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