Jan Luc
0
Q:

str_replace php

<?php
//str_replace("Original Value", "Value to be replaced", "String");
$result = str_replace("1", "2", "This is number 1");
// Output: This is number 2
?>
13
$var1 = 'hello.world';
$var2 = str_replace(".", "-", $var1);
echo $var2; // hello-world
2
echo str_replace("worss","world","Hello worss in PHP!!");
5
// 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;
1
<?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
?>
3

<?php

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

?>

0

<?php

$find = array("Hello","world");

$replace = array("B");

$arr = array("Hello","world","!");

print_r(str_replace($find,$replace,$arr));

?> 
0

<?php

$arr = array("blue","red","green","yellow");

print_r(str_replace("red","pink",$arr,$i));

echo "Replacements: $i";

?> 
0

<!DOCTYPE html>

<html>

<body>


<h1>My First Web Page</h1>

 <p>My first paragraph.</p>


<button type="button" onclick="document.write(5 + 6)">Try it</button>


</body>

</html>
 
0

<?php

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

?> 
0

New to Communities?

Join the community