开发者

PHP: count amount of tabs at the beginning of a string

开发者 https://www.devze.com 2023-02-20 05:18 出处:网络
Ok basically I have a string which could be anything but for the purposes of the question it is: Hello World

Ok basically I have a string which could be anything but for the purposes of the question it is:

    Hello World 

As you can see it has been indented twice at the beginning and once at the end. Is there a way to count the amount of tabs \t only at the开发者_运维百科 beginning of the string with PHP?

Cheers Franky


Try this code, it does exactly what you ask:

strspn($string, "\t");

http://www.php.net/strspn

0

精彩评论

暂无评论...
验证码 换一张
取 消