string replace php
snippet in php

php str_replace

user1740

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

user5931


<?php

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

?> 

str_replace php variable

user7088

$var1 = 'hello.world';
$var2 = str_replace(".", "-", $var1);
echo $var2; // hello-world

php replace string within string

user4216

$new_string = str_replace( $take_out, $put_in, $string);

php replace

user3932

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

string replace php

user2245

#Definition:
  str_replace ( array|string $search , array|string $replace , string|array $subject , int &$count = null ) : string|array

#Simple Example:
echo str_replace("_", " ", "Hello_World_of_PHP");
  // Prints: "Hello World of PHP"

#Complex Example:  
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
/*OR*/ $vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"];
echo str_replace($vowels, "", "Hello World of PHP", $count);
  // Prints: "Hll Wrld f PHP"
echo $count
  // Prints: "4"

#This function is case-sensitive. 
  #Use str_ireplace() for case-insensitive replace.