php取代多個字元的方法:先建立一個PHP範例檔案;然後透過「str_replace($vowels, "","Hello World of PHP");」方法替換多個字串即可。
推薦:《PHP影片教學》
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!");
<?php $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); $onlyconsonants = str_replace($vowels, "","Hello World of PHP"); echo $onlyconsonants; ?>
以上是php 如何替換多個字符的詳細內容。更多資訊請關注PHP中文網其他相關文章!