If you are writing an application on which you need to check the minimum length of a string, I would suggest you use isset() and treat the variable as an array. Each character of the string will be become an element in the array, and you can determine the number of characters by adding 1 at the last element of the array. ( Note that the first character is element 0)

If your string is “oville”, Your array would look something like this:

Array
(
    [0] => o
    [1] => v
    [2] => i
    [3] => l
    [4] => l
    [5] => e
)

As you can see, there are six elements (0-5). So if you want to check whether a string has 6 characters, your PHP code would look something like this:

<?php
if (isset($str[5])) {
     //the string is at least 6 characters.
}
?>

Some say, this method is faster than using strlen(). Well, I’m not going comment on that until I perform a benchmark using of course our simple benchmarking class.