Home  >  Article  >  Backend Development  >  How to remove the first two characters of a string in php

How to remove the first two characters of a string in php

青灯夜游
青灯夜游Original
2022-02-09 18:42:472845browse

php method to remove the first two characters of a string: 1. Use the substr() function, the syntax "substr($str, 2)"; 2. Use the substr_replace() function, the syntax "substr_replace($str , '', 0,2)”.

How to remove the first two characters of a string in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php removes strings The first two characters

1. Use the substr() function

The substr() function can intercept a certain length of characters from the specified position of the string. Character, returns the extracted part of the string, returns FALSE on failure, or returns an empty string.

How to remove the first two characters of a string in php

2. Use the substr_replace() function

substr_replace() function to replace part of a string with another string .

How to remove the first two characters of a string in php

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to remove the first two characters 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