This article mainly introduces the usage of the php string replacement function substr_replace (). The example analyzes the usage skills of the substr_replace function in php, which has some reference value, for more information about how to use the php string replacement function substr_replace (), see the following example. Share it with you 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.
<? 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");?>
Enter the following result in the above code:
Warning: System will shutdown in 15 minutes! (10 minutes later) Warning: System will shutdown in 5 minutes!
I hope this article will help you with php programming.