How this string length example works
strlen() counts bytes, which equals characters for ASCII text. Combine it with str_replace() to ignore certain characters, and use str_word_count() to count words.
Get the length of a string with strlen(). Edit the code below and press Run to execute it with real PHP in your browser.
String: Hello, World! Length: 13 characters Without spaces: 12 Words: 2
strlen() counts bytes, which equals characters for ASCII text. Combine it with str_replace() to ignore certain characters, and use str_word_count() to count words.