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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:02:46
Original
957 people have browsed it

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;>
Copy after login

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!
Copy after login

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...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template