Math Functions II


#1



<?php
rand();
echo rand(5,9);
?>



<?php
$myname = "divyam";
echo strlen("myname");
?>



<?php
$myname = "divyam";
echo $partial= substr($myname,0,3);
?>



<?php
$myname = "divyam";
$rand = $myname[rand(0,strlen($myname)-1)];
echo $rand;
?>



this is the code i made but "Oops, try again. The random output you printed from your name should be a letter." this error is occuring so what can i do for that.
Also i got my output right as
5

6

div

m
like this. please help


#2

This thread explains is perfectly.


#3



<?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 = "eradi";
print strlen ($name);
echo "

";
print rand (0, strlen ($name));
echo "

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

this is the correct code and the problem is a bug in the interface.
SALUDOS DESDE MEXICO LOL :v.


#4

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