In this example you will learn, how to find number of characters in a string in PHP. You can simply use the PHP strlen() function to find the number of characters in a string of text. It also includes the white spaces inside the specified string.
1 2 3 4 5 6 7 | <?php $my_str1 = 'The quick brown fox jumps over the lazy dog.'; echo strlen($my_str1); // Outputs: 44 $my_str2 = ' The quick brown fox jumps over the lazy dog. '; echo strlen($my_str2); // Outputs: 49 ?> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.