I'm displaying some very very long text strings with a show more link. So I need a way to find out how long the string is.
I know I can simply use
If the only thing you need to check if the string is longer then 50 characters, then you can try to check if the 50th character exists.
For example, for a string of 25 chars long I need to know if it's longer then 20 characters or not.
$str = '123456789qwertyuiopasdfgh'; if($str != '') echo 'It is longer'; else echo 'It is not';
I'm not sure if it's faster then simple strlen, but you can try some performance tests C:
UPD: Also, note that the index starts from 0