Get first character of a string… fast!

Strings can be used as arrays of characters in PHP, which allows to use the [] to get character at particular position. Whenever you know exact position of the character you’re looking for, you should use $str[n], instead of substr($str, n, 1), where n is character position. This is much faster method. More here.

Leave a Reply