7.7 Functions


#1

Hi guys i need help with my code
its giving the error "Your printed output from rand() should be an integer" i really don't understand why, i've done what the exercise asked me to do.



<?php
// Use rand() to print a random number to the screen

?>



<?php

  $name = "Leandro Barboza dos Santos";
  $indice = array("L", "e", "a", "n", "d", "r", "o", "B", "a", "r", "b", "o", "z", "a", "d", "o", "S", "a", "n", "t", "o", "s");
 $mod = strlen($name);
 echo ($mod. ", ");

 $mod = rand(0, strlen($mod));
 echo $mod. ", ";

 echo "The chosen letter is : ". $indice[$mod];

 // Use your knowledge of strlen(), substr(), and rand() to
// print a random character from your name to the screen.

?>
</p>


#2

Hi barboza63,

Could you please paste in the link to the exercise...


#3

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