How to remove the first character of string in PHP?

后端 未结 13 2296
一整个雨季
一整个雨季 2020-12-02 06:00
$str=\':this is a applepie :) \';

How to use PHP, Remove the first character :

13条回答
  •  日久生厌
    2020-12-02 06:40

    Update

    After further tests, I don't recommend using this any more. It caused a problem for me when using the updated string in a MySQL query, and changing to substr fixed the problem. I thought about deleting this answer, but comments suggest it is quicker somehow so someone might have a use for it. You may find trimming the updated string resolves string length issues.


    Sometimes you don't need a function:

    $str[0] = '';
    

    For example:

    $str = 'AHello';
    $str[0] = '';
    echo $str; // 'Hello'
    

    This method modifies the existing string rather than creating another.

提交回复
热议问题