Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Created August 11, 2014 08:30
Show Gist options
  • Save JacobHsu/863c3f2c0e44a767abac to your computer and use it in GitHub Desktop.
Save JacobHsu/863c3f2c0e44a767abac to your computer and use it in GitHub Desktop.
#php : strlen(string), rand(min, max), and substr(string, start, length)
<html>
<p>
<?php
// Use rand() to print a random number to the screen
echo rand();
?>
</p>
<p>
<?php
// Use your knowledge of strlen(), substr(), and rand() to
// print a random character from your name to the screen.
$name = "jacob";
echo substr($name ,0, rand( 0, strlen($name)- 1) );
?>
</p>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment