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? Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/ 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). Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/#findComment-777719 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? Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/#findComment-778183 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 Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/#findComment-778188 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); ?> Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/#findComment-778202 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) Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/#findComment-778258 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() Link to comment https://forums.phpfreaks.com/topic/148156-character-count-only-characters/#findComment-778375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.