Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
Word count excluding HTML tags Word count excluding HTML tags PSWorx
How would i go about making a word count on a php variable but excluding all content held within (including) HTML tags?
I would suggest beginning by 'exploding' the string with something like preg_match. That would allow you to look for something that starts with a less than symbol [ ^< ], plus [ + ] ends with a greater than symbol [ $> ]. hakre
regular expression are a really cool thing, but they aren't needed here because of PHP's great set of standard functions: $count = str_word_count(strip_tags($yourtext));
don't forget to checkout the manual on these 2 ones:
...] php.net [ ...] php.net