remove substring from string php code example
Example 1: php remove text from string
<?php
echo str_replace("world","Peter","Hello world!");
?>
Example 2: php replace
str_replace ($search, $replace, $subject);
Example 3: php replace every occurrence of character in string
str_replace ($search, $replace, $subject);
Example 4: replace all php
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");
Example 5: php str replace
<?php
$string = str_ireplace("FoX", "CAT", "the quick brown fox jumps over the lazy dog");
echo $string;
?>