Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to remove the middle characters from php

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article Xiaobian for you to introduce in detail "php how to remove the middle of several characters", the content is detailed, the steps are clear, the details are handled properly, I hope this "php how to remove the middle of several characters" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

In PHP, you can use the "substr_replace ()" function to remove the middle characters, which is used to replace part of a string with another string, just set the replaced part to empty, and the syntax is "substr_replace (string,", remove the character position, remove the number of characters).

This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer

How does php remove the middle characters?

The substr_replace () function replaces part of a string with another string.

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

This function is binary secure.

Grammar

Substr_replace (string,replacement,start,length)

String is required. Specifies the string to check.

Replacement is required. Specifies the string to insert.

Start is required. Specifies where to start the replacement of the string. Positive number-starts at the specified position in the string, negative number-starts at the specified position at the end of the string, 0-starts at the first character in the string

Length is optional. Specifies how many characters to replace. The default is the same length as the string. Positive number-length of string to be replaced, negative number-number of characters replaced from the end of the string, 0-insert instead of replace

Return value: returns the string to be replaced. If string is an array, an array is returned.

Examples are as follows:

Output result:

After reading this, the article "how to remove the characters in the middle of php" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report