title: Replace every character with an element
body: <p><strong>This is what I have</strong></p>
  
  <pre><code>$str = 'Just a &lt;span class="green"&gt;little&lt;/span&gt; -text åäö width 123#';
  </code></pre>
  
  <p><strong>This is what I need</strong></p>
  
  <p>Results in spans and spaces, might be newlines as well.</p>
  
  <pre><code>$result = '&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt; &lt;span&gt;&lt;/span&gt; &lt;span class="green"&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt; &lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt; &lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt; &lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;';
  </code></pre>
  
  <p>You might wonder what I can possible be needing this for. I want to build a thing where ever character is represented by a block. Will look a bit like Defrag on Windows XP.</p>
  
  <p><strong>Question</strong></p>
  
  <ul>
  <li>Replace every character with <code>&lt;span&gt;&lt;/span&gt;</code>.</li>
  <li>Do not touch the HTML span that already exists in the string (might be hard?). There can be more than one HTML element.</li>
  <li>Do not touch spaces and newline.</li>
  <li>Regexp should do it? or Xpath?</li>
  </ul>
  
  <p><strong>What have I done so far?</strong></p>
  
  <p>I have found articles about the regexp but not replacing every character (excerpt space and newline)</p>
  
  <pre><code>$result = preg_replace("/???/", "&lt;span&gt;&lt;/span&gt;", $str);
  print_r($result);
  </code></pre>