php替换多个字符串str_replace函数
//多个字符串分别对应替换,第一和第二个参数的数组长度必须一致,根据数组的指针来替换
echo str_replace(array("m","i"),array("n","z"),"my name is jim!")
//多个字符串换成同一个字符串
echo str_replace(array('m','i'),'n',"my name is jim!");
demo:把字符串中的存在数组中的字符全部替换为空
<?php $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); $onlyconsonants = str_replace($vowels, "","Hello World of PHP"); echo $onlyconsonants; ?>