《PHP編程:php字符串替換函數substr_replace()用法實例》要點:
本文介紹了PHP編程:php字符串替換函數substr_replace()用法實例,希望對您有用。如果有疑問,可以聯系我們。
本文實例講述了php字符串替換函數substr_replace()用法.分享給大家供大家參考.具體分析如下:PHP實例
substr_replace用于在指定字符串中替換指定位置的子字符串PHP實例
<?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"); ?>
上面代碼輸入如下結果PHP實例
Warning: System will shutdown in 15 minutes! (10 minutes later) Warning: System will shutdown in 5 minutes!
希望本文所述對大家的php程序設計有所贊助.PHP實例
《PHP編程:php字符串替換函數substr_replace()用法實例》是否對您有啟發,歡迎查看更多與《PHP編程:php字符串替換函數substr_replace()用法實例》相關教程,學精學透。維易PHP學院為您提供精彩教程。