title: String length problems when using PHP, DOMDocument and XPATH
body: <p>I fetch data with cURL that I parse with DOMDocument and XPATH. strlen() is giving irregular counts.</p>
  
  <p>Some intro code:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $data = curl_exec($ch);     
  $dom = new DOMDocument();
  $dom-&gt;preserveWhiteSpace = false;
  $dom-&gt;loadHTML($data);
  $xpath = new DOMXpath($dom);
  </code></pre>
  
  <p>I fetch the data I need and it works well, but now I need to compare two strings. Original is taken straight from a <code>&lt;li&gt;</code>-tag. Parsed is four or five <code>&lt;span&gt;</code>s joined together.</p>
  
  <pre><code>$original = $i[$n]['full'];
  $parsed = $i[$n]['value'].$i[$n]['type'].$i[$n]['name'].$i[$n]['extra'];
  
  echo $original."&lt;br&gt;";
  echo $parsed."&lt;br&gt;&lt;br&gt;";
  echo strlen($original)."&lt;br&gt;";
  echo strlen($parsed)."&lt;br&gt;&lt;br&gt;";
  </code></pre>
  
  <p>give:</p>
  
  <pre><code>4 -5 boneless chicken breasts
  4-5Boneless chicken breasts
  
  70
  27
  </code></pre>
  
  <p>I started messing around by replacing all spaces, trying mb_strlen with different encodings, typecasting to string, but all to no avail:</p>
  
  <pre><code>$replace = array(' ',',');
  $mod_original = str_replace($replace,'',$original);
  $mod_parsed = str_replace($replace,'',$parsed);
  
  var_dump($mod_original);
  echo "&lt;br&gt;";
  var_dump($mod_parsed);
  echo "&lt;br&gt;&lt;br&gt;";
  
  echo mb_strlen($mod_original,'UTF-8')."&lt;br&gt;";
  echo mb_strlen($mod_parsed,'UTF-8')."&lt;br&gt;";
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>string(62) "4-5 bonelesschickenbreasts" 
  string(25) "4-5Bonelesschickenbreasts" 
  
  62
  25
  </code></pre>
  
  <p>Something is strange. str_replace won't even remove that last whitespace.</p>
  
  <p>Any help is appreciated.</p>