title: Using str_split on a UTF-8 encoded string
body: <p>I'm currently working on a project, and instead of using regular MySQL queries I thought I'd go ahead and learn how to use PDO.</p>
  
  <p>I have a table called contestants, both the database, the table, and all of the columns are in utf-8. I have ten entries in the contestant table, and their column "name" contains characters such as åäö.</p>
  
  <p>Now, when I fetch an entry from the database, and var_dump the name, I get a good result, a string with all the special characters intact. But what I need to do is to split the string by characters, to get them in an array that I then shuffle.</p>
  
  <p>For instance, I have this string:
  <strong>Test ÅÄÖ Tåän</strong></p>
  
  <p>And when I run str_split I get each character in it's own key in an array. The only issue is that all the special characters display as this: �, meaning the array will be like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; T
      [1] =&gt; e
      [2] =&gt; s
      [3] =&gt; t
      [4] =&gt;  
      [5] =&gt; �
      [6] =&gt; �
      [7] =&gt; �
      [8] =&gt; �
      [9] =&gt; �
      [10] =&gt; �
      [11] =&gt;  
      [12] =&gt; T
      [13] =&gt; �
      [14] =&gt; �
      [15] =&gt; �
      [16] =&gt; �
      [17] =&gt; n
  )
  </code></pre>
  
  <p>As you can see, it not only messes up the characters, but it also duplicates them in str_split process. I've tried several ways to split the string, but they all have the same issue. When I output the string before the split, it shows the special characters just fine.</p>
  
  <p>This is my dbConn.php code:</p>
  
  <p>// Require config file:
      require_once('config.inc.php');</p>
  
  <pre><code>// Start PDO connection:
  $dbHandle = new PDO("mysql:host=$dbHost;dbname=$dbName;charset=utf-8", $dbUser, $dbPass);
  $dbHandle -&gt; exec("SET CHARACTER SET utf8");
  
  // Set error reporting:
  $dbHandle-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  </code></pre>
  
  <p>And this is the code that I use to fetch from the database and loop:</p>
  
  <pre><code>// Require files:
  require_once('dbConn.php');
  
  // Get random artist:
  $artist = $dbHandle-&gt;query("SELECT * FROM ".ARTIST_TABLE." WHERE id = 11 ORDER BY RAND() LIMIT 1");
  $artist-&gt;setFetchMode(PDO::FETCH_OBJ);
  $artist = $artist-&gt;fetch();
  var_dump($artist-&gt;name);
  
  // Split name:
  $artistChars = str_split($artist-&gt;name);
  </code></pre>
  
  <p>I'm connecting with utf-8, my php file is utf-8 <strong>without BOM</strong> and no other special characters on this page share this issue. What could be wrong, or what am I doing wrong?</p>