Use isset() Instead of strlen()

This is actually a new trick, here is the example:

if (isset($username[5]))
 // The username is at least six characters long. 

When you use string as an array, then each character of string is an element in the array. When you check whether an element exist and of atleast that many characters long.

The reason of using isset() is slightly faster than strlen().  strlen() is a function and isset() is a language construct.

Leave a Reply

Your email address will not be published. Required fields are marked *