Home > Backend Development > PHP Problem > How to replace multiple characters in php

How to replace multiple characters in php

藏色散人
Release: 2023-03-06 21:54:02
Original
3003 people have browsed it

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.

How to replace multiple characters in php

Recommended: "PHP Video Tutorial"

php replace multiple strings str_replace function

echo str_replace(array("m","i"),array("n","z"),"my name is jim!")
Copy after login
echo str_replace(array('m','i'),'n',"my name is jim!");
Copy after login
<?php 
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "","Hello World of PHP");
echo $onlyconsonants;
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template