To find the length of a string in PHP, you can use the strlen()
function. This function returns the number of characters in the string.
For example:
$string = 'Hello';
$length = strlen($string);
// $length will be equal to 5
You can also use the mb_strlen()
function to find the length of a string in bytes, or to count the number of characters in a multibyte string. This function requires the mbstring
extension to be enabled in your PHP configuration.
For example:
$string = 'Hello';
$length = mb_strlen($string, 'UTF-8');
// $length will be equal to 5