Jump to content
Larry Ullman's Book Forums

How To Get A String Lenght Without The Spaces?


Recommended Posts

I read it as string length without spaces rather than word count. But I'll include methods for both.

 

For string length without spaces:

$string_length = strlen($string) - substr_count($string, ' ');

For word count:

$word_count = str_word_count($string, 0);

  • Upvote 2
Link to comment
Share on other sites

 Share

×
×
  • Create New...