PHP Subtract First Character of String

2019-01-20 12:21发布

I know this is simple, and I've done it before, but I've forgotten how to do it.

How might I, in php, subtract the first letter of a string?

For example:

FOOBAR would become OOBAR

I think its something like $string[-1];

3条回答
戒情不戒烟
2楼-- · 2019-01-20 13:12

If you are echoing the string out, then use:

$string[0] = '';

It's over an order of magnitude faster than:

substr($string, 1);

However, for anything else (eg accessing a database) it can cause problems and should be avoided.

查看更多
来,给爷笑一个
4楼-- · 2019-01-20 13:21

substr ( $string , 1 ,strlen($string) )

查看更多
登录 后发表回答