#69. PHP String Replace Functions
How to work PHP String Replace Functions?
Syntax & E.g.
<?php
$str = "I love Programming. I am a Programmer";
$find = ["I","love", "Programming"];
$replace = ["","Hi","Programmer"];
echo str_replace("love", " ", $str);
echo str_replace($find, $replace, $str);
str_ireplace case-insensitive
echo str_ireplace($find, $replace, $str);
?>
<?php
$str = "I love Programming. I am a Programmer";
// $find = ["I","love", "Programming"];
// $replace = ["","Hi","Programmer"];
//$array = ["Civic","Corola","Alto"];
//substr_replace
//echo substr_replace($str, "Programmer",7,13);
// Replace in Array function
// echo "<pre>";
// print_r(str_replace("Civic", "Sazuki",$array));
// echo "</pre>";
?>
Run Code:
<?php
$str = "I love Programming. I am a Programmer";
//strtr
echo strtr($str, "ve", "ly");
?>




Comments
Post a Comment