title: strlen, rand and substr in PhP
body: <pre><code>&lt;?php
      $name = "Freddy";
      $len = strlen($name);
      $rand = rand(0, $len - 1);
      echo substr($name ,$rand, $rand - 1);
  ?&gt;
  </code></pre>
  
  <p>The php code is supposed to echo only one character of the name(Using strlen, rand and substr) ,yet that only happens sometimes. I believe this is a problem with the variable $rand, yet after two days of amateur code staring, I am not so sure. help would be greatly appreciated</p>
  
  <p><p>As I understand it:<br></p>
  
  <ul>
      <li>$name = "Freddy"</li>
      <li>$len = 5</li>
      <li>$rand = 0-4</li>
  </ul>