龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

字符串替换 php字符串替换函数substr_replace()使用代码演示

时间:2014-10-03 11:05来源:网络整理 作者:网络 点击:
分享到:
php字符串替换函数substr_replace()使用代码演示 [代码片段(10行)] 上面代码输入如下结果
<?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");
?>

                                上面代码输入如下结果
Warning: System will shutdown in 15 minutes!
(10 minutes later)
Warning: System will shutdown in 5 minutes!
精彩图集

赞助商链接