英[r??ple?s]? ?美[r??ples]??
vt.代替;替換;把…放回原位;(用…)替換
第三人稱單數(shù): replaces 現(xiàn)在分詞: replacing過去式: replaced 過去分詞: replaced
php substr_replace()函數(shù) 語法
作用:替換字串中某字串為另一個字串
語法:substr_replace(string,replacement,start,length)
參數(shù):
參數(shù) | |
#string? ?? | 必需。規(guī)定要檢查的字串。 |
replacement? | 必要。規(guī)定要插入的字串。 |
start? ?? | 必要。規(guī)定在字串的何處開始替換。正數(shù) - 在字串中的指定位置開始替換,負(fù)數(shù) - 在從字串結(jié)尾的指定位置開始替換,0 - 在字串中的第一個字元開始替換。 |
length? ?? | 可選。規(guī)定要替換多少個字元。預(yù)設(shè)是與字串長度相同。正數(shù) - 被替換的字串長度,負(fù)數(shù) - 表示待替換的子字串結(jié)尾處距離?string?末端的字元個數(shù)。 0 - 插入而非替換 |
說明:把字串的一部分替換為另一個字串。若?start?參數(shù)是負(fù)數(shù)且?length?小於或等於?start,則?length?為 0。該函數(shù)是二進(jìn)制安全的。
php substr_replace()函數(shù) 範(fàn)例
輸出:
Hello php.cn
############# #輸出:######
i like php