PHP Subtract/Remove First Character of String

前端 未结 3 761
春和景丽
春和景丽 2020-12-11 20:44

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

In PHP, how might I subtract or remove the first letter of a string?

相关标签:
3条回答
  • 2020-12-11 20:55

    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.

    0 讨论(0)
  • 2020-12-11 21:03
    substr($string, 1)
    

    http://php.net/manual/en/function.substr.php

    0 讨论(0)
  • 2020-12-11 21:09

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

    0 讨论(0)
提交回复
热议问题