web_master Posted March 5, 2009 Share Posted March 5, 2009 Hi, I got in MySql database the text. The text looks like this example: <p>Ommy num <strong>ad modip ea accum</strong> ea commy num <em>aut iliquam etueraestis nullao</em>r sequi blaor atem diamconullum ip eu feugiam, verosto eratisi.</p> <p><br />Lorem dolutpatet veniametum dit ilis dolum vel ipit autem exero eugue digna facin vendre magna faciliquamet irit do do erciduis alit aliscilit wis ex ea at. Gait, quis nonsequamet amet, volobore volore molorem zzrit vel ut alit nos <span style="color: #ff0000;">nibh eu facilit lore</span> venim delent alisi tie dio exer adit, vullumsan žŽ Å‘Å éÉ ÑˆÐ¨Ð¨Ñ›Ñ› vel ipsum nonulla ortisis del utat, consendre magniscing ea facil dolorero odoluptat. Metummo dolore faciliquisi ting eu feugait utpatum vel utpatum vel exerosto od ecte velit esecte faccummy nonsectem <span style="text-decoration: line-through;">quat amet la feugue tet,</span> quis aliquat.<br /></p> So, when I reload it from MySQl database, how can I count only characters without TAG's like: <span style="color: #ff0000;"> or <p><br /> or others? Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 5, 2009 Share Posted March 5, 2009 strip_tags first, count_chars later (for example). Quote Link to comment Share on other sites More sharing options...
web_master Posted March 6, 2009 Author Share Posted March 6, 2009 OK, I try strip_tags() and strlen() and add the html_entity_decode() too, but its not enough form me. Why? I got the serbian characters like: čČćĆđ𚊞Ž (this is 10 character). In HTML code: čČćĆđ𚊞Ž (this is 32 character) The code is: <?php $CharsPreCOunt = strip_tags(html_entity_decode($request['text'])); echo strlen($CharsPreCOunt); ?> What can I do to counter count 10 characters? Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 6, 2009 Share Posted March 6, 2009 Set UTF-8 encoding for html_entity_decode and use mb_strlen Quote Link to comment Share on other sites More sharing options...
web_master Posted March 6, 2009 Author Share Posted March 6, 2009 Fatal error: Call to undefined function: mb_strlen() in D:\folder\folder\view_txt.php on line 161 I Use it like this: <?php $CharsPreCOunt = strip_tags(html_entity_decode($request['text'])); echo mb_strlen($CharsPreCOunt); ?> Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 6, 2009 Share Posted March 6, 2009 Check if mbstring extension is enabled (and if not, enable it) Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted March 6, 2009 Share Posted March 6, 2009 You could also try iconv_strlen() as an alternative to mb_strlen() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.