php str replace
snippet in php

php str_replace

user7524

<?php
//str_replace("Original Value", "Value to be replaced", "String");
$result = str_replace("1", "2", "This is number 1");
// Output: This is number 2
?>

php string replace

user8068


<?php

echo str_replace("world","Peter","Hello world!");

?> 

php replace

user2665

str_replace ($search, $replace, $subject);

str_replace php

user923

echo str_replace("worss","world","Hello worss in PHP!!");

php str replace

user7826

<?php
$string = str_ireplace("FoX", "CAT", "the quick brown fox jumps over the lazy dog");
echo $string; // the quick brown CAT jumps over the lazy dog
?>

str_replace

user9639

// Génère : <body text='black'>
$bodytag = str_replace("%body%", "black", "<body text='%body%'>");

// Génère : Hll Wrld f PHP
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");

// Génère : You should eat pizza, beer, and ice cream every day
$phrase  = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy   = array("pizza", "beer", "ice cream");

$newphrase = str_replace($healthy, $yummy, $phrase);

// Génère : good goy miss moy
$str = str_replace("ll", "", "good golly miss molly!", $count);
echo $count;