title: Why do some characters lose when I use str_shuffle() in PHP?
body: <p>This is the code in lib.php:</p>
  
  <pre><code>&lt;?php
  
  class table {
  
      function __construct($string, $time) {
  
          $out = '&lt;table cellpadding="5"&gt;';
          $out .= $this-&gt;getRow('th', 'Nom., Shuffled String, Lenght');
  
          for ($x = 1; $x &lt;= $time; $x++) {
  
              $shuffledStr = str_shuffle($string); //Maybe this causes the problem
              $shuffledStr_len = strlen($shuffledStr);
              $out .= $this-&gt;getRow('td', $x . ', ' . $shuffledStr . ', ' . $shuffledStr_len);
          }
  
          $out .= '&lt;/table&gt;';
  
          echo $out;
      }
  
      public function getRow($tagName, $contents_list) {
  
          //Variables:
          $out = '';
          $contents_array = explode(', ', $contents_list);
          $contents_number = count($contents_array);
          $start_tag = '&lt;' .  $tagName . '&gt;';
          $end_tag = '&lt;/' .   $tagName . '&gt;';
  
          // Build
          $out .= '&lt;tr&gt;';
  
          for ($i = 0; $i &lt; $contents_number; $i++) {
              $out .= $start_tag . $contents_array[$i] . $end_tag;
          }
  
          $out .= '&lt;/tr&gt;';
  
          return $out;
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>And here is index.php:</p>
  
  <pre><code>    &lt;?php
  require_once 'lib.php';
  $string = ''; //My string
  $shuffleTimes = 100;
  $table = new table($string, $shuffleTimes);
  ?&gt;
  </code></pre>
  
  <p>This program gets the a string and the number that you wanna shuffle, 
  then create a table and returns the number, shuffled string and the length of the shuffle string in each row.</p>
  
  <p>If I set the variable <code>$string</code> to 'Stack Overflow' for instance it'll work correctly (It shuffles this word 100 times randomly, returns all lengths 14 and the length of the <strong>ALL</strong> shuffled strings are really 14.)</p>
  
  <p>But...</p>
  
  <p>If I add some special character to the variable <code>$string</code> (for example <code>Stack Overflow+_)(*&amp;^%$#{}[]&lt;&gt;@!~./=-</code>) it won't work correctly. That means it returns the lengths 37 But they doesn't have 37 characters!(For example it printed <code>nothing</code> and printed it's lenght <code>38</code>.
  I think it's a bit strange. :(</p>
  
  <p>Why is that?! Which character causes that and how to fix it?</p>