bahaa Posted November 23, 2011 Share Posted November 23, 2011 How do we get the length of a string without the spaces? I want to count only the words without the spaces. Link to comment Share on other sites More sharing options...
Jonathon Posted November 23, 2011 Share Posted November 23, 2011 explode it and count the array? 1 Link to comment Share on other sites More sharing options...
rob Posted November 25, 2011 Share Posted November 25, 2011 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); 2 Link to comment Share on other sites More sharing options...
Larry Posted November 28, 2011 Share Posted November 28, 2011 Nice solution, Rob! Link to comment Share on other sites More sharing options...
Recommended Posts