字符串替换 php字符串替换函数substr_replace()使用代码演示
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!
精彩图集
精彩文章