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)”.
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.
<?php $str = "hello,world"; $str2 = substr($str, 2); echo $str2; ?>
2. Use the substr_replace() function
substr_replace() function to replace part of a string with another string .
<?php $str = "world"; $str2 = substr_replace($str, '', 0,2); echo $str2; ?>
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
