165-PHP 文本替换函数str_replace(六)
生活随笔
收集整理的這篇文章主要介紹了
165-PHP 文本替换函数str_replace(六)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<?php$str='programming'; //定義一個字符串$replacement='er'; //定義替換的字符串$res=substr_replace($str,$replacement,8); //處理字符串echo "{$str}執行替換后的效果:<br />{$res}";
?>
?
<?php$str='programming'; //定義一個字符串$replacement='er'; //定義替換的字符串$res=substr_replace($str,$replacement,-4); //處理字符串echo "{$str}執行替換后的效果:<br />{$res}"; ?> <?php$str='programming'; //定義一個字符串$replacement='er'; //定義替換的字符串$res=substr_replace($str,$replacement,-4,1); //處理字符串echo "{$str}執行替換后的效果:<br />{$res}"; ?> <?php$str='programming'; //定義一個字符串$replacement='er'; //定義替換的字符串$res=substr_replace($str,$replacement,-4,-1); //處理字符串echo "{$str}執行替換后的效果:<br />{$res}"; ?> <?php$str='programming'; //定義一個字符串$replacement='er'; //定義替換的字符串$res=substr_replace($str,$replacement,-4,0); //處理字符串echo "{$str}執行替換后的效果:<br />{$res}"; ?>?
轉載于:https://www.cnblogs.com/tianpan2019/p/11037741.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的165-PHP 文本替换函数str_replace(六)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转]进程,线程和多线程
- 下一篇: amd和cmd区别