How to Find the length of a string in PHP
In this tutorial, we are going to learn about how to get the length of a given string in PHP.
Getting the string length
To get the length of a string, we can use the built-in strlen()
function in PHP.
The
strlen()
function takes the string as an argument and returns the total number of characters in it.
Here is an example, that gets the length of a name
string:
$name = "lincoln";
$length = strlen($name);
echo $length;
Output:
7