title: PHP - iterate on string characters
body: <p>Is there a nice way to iterate on the characters of a string?  I'd like to be able to do <code>foreach</code>, <code>array_map</code>, <code>array_walk</code>, <code>array_filter</code> etc. on the characters of a string.</p>
  
  <p>Type casting/juggling didnt get me anywhere (put the whole string as one element of array), and the best solution I've found is simply using a for loop to construct the array.  It feels like there should be something better.  I mean, if you can index on it shouldn't you be able to iterate as well?</p>
  
  <p>This is the best I've got</p>
  
  <pre><code>function stringToArray($s)
  {
      $r = array();
      for($i=0; $i&lt;strlen($s); $i++) 
           $r[$i] = $s[$i];
      return $r;
  }
  
  $s1 = "textasstringwoohoo";
  $arr = stringToArray($s1); //$arr now has character array
  
  $ascval = array_map('ord', $arr);  //so i can do stuff like this
  $foreach ($arr as $curChar) {....}
  $evenAsciiOnly = array_filter( function($x) {return ord($x) % 2 === 0;}, $arr);
  </code></pre>
  
  <p>Is there either:</p>
  
  <p>A) A way to make the string iterable<br>
  B) A better way to build the character array from the string  (and if so, how about the other direction?)</p>
  
  <p>I feel like im missing something obvious here.</p>