Home  >  Article  >  Backend Development  >  How to delete the first character of a string in php

How to delete the first character of a string in php

藏色散人
藏色散人Original
2020-05-08 13:32:034889browse

How to delete the first character of a string in php

php method to delete the first character of a string

You can use the substr function to delete a string in PHP first character.

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 - Return from the position of the start parameter

Negative number - Return from the end of the string

<?php
echo substr("Hello world",1);
?>

Running result:

ello world

Recommended : "PHP Tutorial"

The above is the detailed content of How to delete the first character of a string in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn