strlen():
This function returns the number of characters in a string. It takes a string as an argument. This means The strlen function in PHP is used to return the length of a string. The syntax of the strlen function is:
strlen ('string')
Let's take a look at the examples below:
Example 1
<?php
echo strlen('PHP arrays');
?>
Example 2
<?php
echo strlen(' PHP arrays ');
?>
From the above, we see that spaces count towards string length just like a character does.
Example 3
<&?php $str = "Hello!"; echo strlen($str); ?>