find the length of a string in php

To find the length of a string in PHP, you can use the built-in strlen() function. Here's an example:

main.php
$str = "Hello, world!";
$length = strlen($str);
echo $length; // Output: 13
76 chars
4 lines

In the example above, we first define a string variable $str that contains the text "Hello, world!". We then use the strlen() function to find the length of the string, and store the result in the variable $length. Finally, we use the echo statement to output the length, which in this case is 13.

gistlibby LogSnag