SQL PHP HTML ASP JavaScript articles and free scripts to download
 

PHP String length counting by strlen

How to count the length of a PHP string? This function is required to check some form validation also where any input field is entered blank. PHP function strlen does this work for us and returns number of characters inside the string including blank space. If you want blank space to be removed then you can apply string replace function str_replace to the string before applying strlen.


<?

$string="This is my string";

echo "Length of the string = ".strlen($string);

?>




Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked


Join Our Email List
Email:  
For Email Newsletters you can trust
String Functions
PHP Sections