Mega Code Archive

 
Categories / Php / Code Snippets
 

This example shows how you can get the length of a string , this uses

the function strlen() <?php //display length of string(s) $string1 = "beginners php"; $string2 = "myscripting"; //store the length of the strings in variables $length1 = strlen($string1); $length2 = strlen($string2); //display the length of the strings echo "String1 has $length1 characters"; echo "String2 has $length2 characters"; ?>