This might be one of the easiest things you’ll ever do, in PHP to be precise. To get the length of a string in PHP you use the
strlen() function. It takes a string as its argument and returns the length of the string, the amount of individual characters with spaces, tabs, line breaks, etc. included.
<?php echo strlen('four'); # => 4
In case you want to check if a string is empty you could better use the
empty() function. Which checks whether a variable is empty.