php字符串替换函数substr_replace()使用示例

前端之家收集整理的这篇文章主要介绍了php字符串替换函数substr_replace()使用示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP字符串替换函数substr_replace()使用代码演示感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
substr_replace用于在指定字符串中替换指定位置的子字符串

/**
 * PHP字符串替换函数substr_replace()使用代码演示
 *
 * @param 
 * @arrange 512-笔记网: 512Pic.com
 **/
$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",2)."\n");

/***   来自编程之家 jb51.cc(jb51.cc)   ***/
上面代码输入如下结果
Warning: System will shutdown in 15 minutes!
(10 minutes later)
Warning: System will shutdown in 5 minutes!

猜你在找的PHP相关文章