How To Find String Length in PHP

How To Find String Length in PHP

In this tutorial we will learn How To Find String Length in PHP. PHP strlen() function can be used to find the length of string or number of characters present in string.

Using strlen() Function

We can simply use strlen() Function to find string length in PHP.

strlen() Function is a built-in PHP function which returns the length of string or number of characters present in the string.

Take a look at the code given below.

<?php
$string = 'HowToCodeSchool.com';
$stringLength = strlen($string);
echo $stringLength;
?>

$stringLength variable contains the length of the original string.

strlen() Function is supported in PHP 4+ versions, so you can use it anywhere.

Output

19

Comments

Popular posts from this blog

Gove confirms mandatory housebuilding targets for councils will be abolished in face of Tory rebellion – UK politics live

Kotak Mahindra Bank Recruitment 2022 Released for Graduate Candidates And Apply Online