counting characters in php
<p>I want to count how many characters a certain string has in PHP, but I cant get it to work.</p>

<p>I did a var_dump and this is what I got:</p>

<pre><code>string(23) "Children&amp;#8217;s Center"
</code></pre>

<p>It seems like <code>'</code> gets translated to <code>&amp;#8217;s</code> </p>

<p>This makes it impossible to get the actual character count. I tried using <code>html_entity_decode</code> but it did not help.</p>

<p>Anyone?</p>

<p>EDIT:
My function looks like this now:</p>

<pre><code>function make_shorter($string, $maxlength)
{
 $string = stripslashes($string);   
 $string = html_entity_decode($string);
 if ( mb_strlen(utf8_decode($string)) &gt; $maxlength)
  return substr($string,0,$maxlength).'...';
 else
  return $string;
}
</code></pre>

<p>I can't change how the data gets in to the system. I can only modify it's output.</p>

<p>(It's a wordpress site)</p>
