Matija Nalis
0
Q:

php str replace

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

<?php

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

?> 
0
echo str_replace("worss","world","Hello worss in PHP!!");
5
<?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>

    
<p id="demo"></p>



<script>

 document.getElementById("demo").innerHTML = 5 + 6;

    </script>



</body>

</html>
 
0

<?php

$str = "Hello World";

echo str_pad($str,20,".");

?> 
0

New to Communities?

Join the community