Home  >  Article  >  Backend Development  >  PHP string replacement function substr_replace() usage example, substrreplace_PHP tutorial

PHP string replacement function substr_replace() usage example, substrreplace_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:02:46893browse

Usage examples of php string replacement function substr_replace(), substrreplace

This article describes the usage of php string replacement function substr_replace(). Share it with everyone for your reference. The specific analysis is as follows:

substr_replace is used to replace the substring at the specified position in the specified string

<&#63;php
$string = "Warning: System will shutdown in NN minutes!";
$pos = strpos($string, "NN");
print(substr_replace($string, "15", $pos, 2)."\n");
sleep(10*60);
print(substr_replace($string, "5", $pos, 2)."\n");
&#63;>

Enter the above code and the following results

Warning: System will shutdown in 15 minutes!
(10 minutes later)
Warning: System will shutdown in 5 minutes!

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969503.htmlTechArticlephp string replacement function substr_replace() usage example, substrreplace This article describes the php string replacement function substr_replace() usage. Share it with everyone for your reference. Detailed analysis...
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