Wednesday, July 21, 2010

How to get number of characters of a String in php - strlen()

You can use strlen() to easily find the length of an php string.

<?php
$str = 'Hello World';
echo strlen($str); // 11
?>

Many new php developers make the mistake of using count() which is used to count elements in an array or properties in an object.

No comments:

Post a Comment