title: How to iterate UTF-8 string in PHP?
body: <p>How to iterate a UTF-8 string character by character using indexing?</p>
  
  <p>When you access a UTF-8 string with the bracket operator <code>$str[0]</code> the utf-encoded character consists of 2 or more elements. </p>
  
  <p>For example:</p>
  
  <pre><code>$str = "Kąt";
  $str[0] = "K";
  $str[1] = "�";
  $str[2] = "�";
  $str[3] = "t";
  </code></pre>
  
  <p>but I would like to have:</p>
  
  <pre><code>$str[0] = "K";
  $str[1] = "ą";
  $str[2] = "t";
  </code></pre>
  
  <p>It is possible with <code>mb_substr</code> but this is extremely slow, ie.</p>
  
  <pre><code>mb_substr($str, 0, 1) = "K"
  mb_substr($str, 1, 1) = "ą"
  mb_substr($str, 2, 1) = "t"
  </code></pre>
  
  <p>Is there another way to interate the string character by character without using <code>mb_substr</code>?</p>