Q:

How to find number of characters in a string in PHP

0

How to find number of characters in a string in PHP

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the PHP strlen() function

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.

Let's take a look at the following example to understand how it basically works:

<?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
?>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP  and MySQL Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to find the number of words in a string in PHP... >>
<< How to remove white space from a string in PHP...