How to remove the first character in php

青灯夜游
Release: 2023-03-09 08:28:02
Original
3693 people have browsed it

In PHP, you can use the substr() function to remove the first character of a string. The syntax format is "substr("String",1)". The substr() function is used to return a part of a string. When the value of the second parameter is 1, it means that the return starts from the second character of the string, and the first character can be removed.

How to remove the first character in php

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

php removes the first part of the string characters

In PHP, you can use the substr() function to remove the first character of a string.

Example:

<?php
header(&#39;content-type:text/html;charset=utf-8&#39;);
$str="Hello world!";
echo "原字符串:",$str,"<br>";
$str2=substr($str,1);
echo "去掉第一个字符后的字符串:",$str2,"<br>";
?>
Copy after login

Output:

原字符串:Hello world!
去掉第一个字符后的字符串:ello world!
Copy after login

Related function introduction:

substr() function returns a string a part of. The syntax is as follows:

substr(string,start,length)
Copy after login

How to remove the first character in php

Description: If the start parameter is a negative number and length is less than or equal to start, length is 0.

Return value: Returns the extracted part of the string, returns FALSE if it fails, or returns an empty string.

Recommended learning: "PHP Video Tutorial"

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template