Welcome Guest, Not a member yet? Register   Sign In
Word_limiter word count

(07-13-2020, 01:21 AM)marcogmonteiro Wrote: That's really odd, must be something fishy with the string you're using. Can you do a dd() of said string and put it here?

Good Morning,

Full String:
$str = "<p><span style=\"font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; text-align: justify; background-color: #ffffff;\">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</span></p>";

Output of dd():
$str string (751) "<p><span style="font-family: 'Open Sans', Arial, sans-serif; font-size: 14px...

Output of word_limiter:
PHP Code:
echo word_limiter($str,25);
It is a long established fact that a reader will be distracted by the… 

It does appear to count the words in the HTML as part of the string.
I tried the same string, stripped of html, in a second run (not shown for brevity but can be posted if needed), the string was smaller obviously (613) and the word_limiter showed the full first 25 words.
For my purposes, its not a deal breaker by any stretch since I am the only one going to be using this app I am developing, and will know this limitation. But it should be noted somewhere for others, that HTML text will be counted as part of the string alongside the "clean" text that's used as an example in the docs for this function.

Messages In This Thread
Word_limiter word count - by stlake2011 - 07-12-2020, 02:32 PM
RE: Word_limiter word count - by marcogmonteiro - 07-13-2020, 01:21 AM
RE: Word_limiter word count - by stlake2011 - 07-13-2020, 04:48 AM

Theme © iAndrew 2016 - Forum software by © MyBB