Home >Backend Development >PHP Problem >php replace multiple strings

php replace multiple strings

藏色散人
藏色散人Original
2021-02-08 10:15:462388browse

How to replace multiple strings in php: first create a PHP sample file; then replace multiple strings through the "tr_replace($vowels, "","Hello World of PHP");" method .

php replace multiple strings

The operating environment of this article: Windows 7 system, PHP version 5.6, DELL G3 computer.

str_replace function

php replaces multiple strings

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;
?>

Recommended: "PHP Video Tutorial"

The above is the detailed content of php replace multiple strings. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn