Doing the right calculation I still get the error


#1
<html>
<p>
 
  <?php

print rand(1, 100)
?>

<?php
$name="Waheed";
$char = substr($name, 4, 1); 
rand(0, strlen($name) - 1);
print $char;
?>
</p>
</html>



Despite doing the right calculation I still get the error (the random output you printed from your name should be one character)

could you help please?


How to use the rand() function on a string?
#2

Break the two segments into standalone paragraphs from the HTML side.

</p>
<p>

It makes more sense to me, and may likely be how the author thought.


#3

Thanks for the above advise. but I still have the error and this time it is showing the error (your printed output from rand() should be an integar


#4

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