Home > Article > Backend Development > How to replace multiple characters in php
How to replace multiple characters in php: First create a PHP sample file; then replace multiple strings through the "str_replace($vowels, "","Hello World of PHP");" method.
Recommended: "PHP Video Tutorial"
php replace multiple strings str_replace function
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; ?>
The above is the detailed content of How to replace multiple characters in php. For more information, please follow other related articles on the PHP Chinese website!