str_replace
snippet in php

php str_replace

user8904

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

user1772

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

str_replace php

user7887

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

replace all php

user9736

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

str_replace

user7193

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