php字符串替换函数substr_replace()用法实例
2015-03-17 15:30
1001 查看
substr_replace用于在指定字符串中替换指定位置的子字符串
<?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!
希望本文所述对大家的php程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- php中正则替换函数ereg_replace用法实例
- PHP字符串替换str_replace()函数4种用法详解
- PHP字符串替换str_replace()函数4种用法详解
- php中正则替换函数ereg_replace用法实例
- PHP 字符串替换 substr_replace 与 str_replace 函数
- PHP 字符串替换 substr_replace 与 str_replace 函数
- php中正则替换函数ereg_replace用法实例
- 详解PHP字符串替换str_replace()函数四种用法
- php中常用的字符串截取函数mb_substr实例解释
- php中的字符串常用函数(三) str_replace() 子字符串替换
- php字符串分割函数用法实例
- php中常用的字符串截取函数mb_substr实例解释
- php获取字符串前几位的实例(substr返回字符串的子串用法)
- PHP 字符串正则替换函数preg_replace使用说明
- PHP字符串正则替换函数preg_replace
- php中的字符串常用函数 str_replace 字符串替换,替换全角空格
- php函数之子字符串替换 str_replace
- PHP中substr函数字符串截取用法分析
- PHP中str_replace字符串替换函数详解
- PHP中substr函数字符串截取用法分析