PHP String str_ireplace()函數(shù)
PHP string str_ireplace()是預(yù)定義的函數(shù)。愛掏網(wǎng) - it200.com它用于將某個字符替換為其他字符。愛掏網(wǎng) - it200.com它是str_replace()的不區(qū)分大小寫版本。愛掏網(wǎng) - it200.com
注意:此函數(shù)是二進制安全的。愛掏網(wǎng) - it200.com
str_ireplace(find,replace,string,count);
參數(shù) | 描述 | 必填/可選 |
---|---|---|
find | 指定要查找的值。愛掏網(wǎng) - it200.com | 必填 |
replace | 指定要替換的值。愛掏網(wǎng) - it200.com | 必填 |
string | 指定要搜索的字符串。愛掏網(wǎng) - it200.com | 必填 |
Count | 它是計算替換次數(shù)的變量。愛掏網(wǎng) - it200.com | 可選 |
示例1
<?php
echo "with using 'str_ireplace()' functionL:('PHP','JAVA','PYTHON','RUBY')";
echo "<br>";
echo "By using 'str_ireplace()' function: ".str_ireplace("PHP","JAVA","PYTHON!");
?>
使用’str_ireplace()’函數(shù):(‘PHP’,’JAVA’,’PYTHON’,’RUBY’)
使用’str_ireplace()’函數(shù): PYTHON!
<?php
arr = array("PHP","JAVA","PYTHON","RUBY");
echo "Your array string is: array('PHP','JAVA','PYTHON','RUBY')";
echo "<br>";
print_r(str_ireplace("PHP","JAVA",arr,i)); // This function is case-insensitive
echo "Replacements:i";
?>
輸出:
Your array string is: array('PHP','JAVA','PYTHON','RUBY')
Array ( [0] => JAVA [1] => JAVA [2] => PYTHON [3] => RUBY ) Replacements: 1
示例2
<?php
//Case-insensitive
find = array("PHP","JAVA");
echo "Before using 'str_ireplace()': array('PHP','JAVA')";
echo "<br>";replace = array("B");
arr = array("PHP","java","!");
echo "After using 'str_ireplace()':array('PHP','java','!')";
echo "<br>";
print_r(str_ireplace(find,replace,arr));
?>
輸出:
Before using 'str_ireplace()': array('PHP','JAVA')
After using 'str_ireplace()':array('PHP','java','!')
Array ( [0] => B [1] => [2] => ! )
聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進行處理。