Php character replacement method starting from the specified position

Source: Internet
Author: User
Tags php tutorial


Definition and usage
The substr_replace () function replaces one part of the string with another.

Syntax
Substr_replace (string, replacement, start, length)

<? Php Tutorial
Echo substr_replace ("hello world", "earth", 6 );
?>

Parameters Description
String Required. Specifies the string to be checked.
Replacement Required. Specifies the string to be inserted.
Start

Required. Specifies where the string starts replacement.

  • Positive number-inStartOffset start to replace
  • Negative number-the number at the end of the stringStartOffset start to replace
  • 0-START replacement at the first character in the string
Charlist

Optional. Specifies the number of characters to replace.

  • Positive number-length of the string to be replaced
  • Negative number-Number of replaced characters starting from the end of the string
  • 0-insert instead of replace

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.