Home > Article > Backend Development > How to remove the first string in php
php method to remove the first string of a string; first create a PHP code sample file; then enter the code statement as "substr('string',1);"; finally execute it in the browser This file can successfully remove the first string in the specified string.
Delete the first character of the string
substr('string',1) ;
substr() function definition and usage
substr() function returns a part of a string.
Note: If the start parameter is negative and length is less than or equal to start, length is 0.
Syntax
substr(string,start,length)
Parameters
string Required. Specifies a part of the string to be returned.
start Required. Specifies where in the string to begin.
Positive number - starts at the specified position in the string
Negative number - starts at the specified position from the end of the string
0 - at the first character in the string Start at
length Optional. Specifies the length of the string to be returned. The default is until the end of the string.
Positive number - Returns from the position of the start parameter
Negative number - Returns from the end of the string
Return value: Returns the extracted part of the string, returns FALSE if it fails , or return an empty string.
Update log: In PHP 5.2.2 to 5.2.6 versions, if the start parameter represents a negative truncation or an out-of-bounds position, FALSE is returned. Other versions get the string starting at the start position.
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to remove the first string in php. For more information, please follow other related articles on the PHP Chinese website!