PHP str_ireplace() Function
The str_ireplace()
is function is used to replace some character with some other characters.
Syntax
str_ireplace(find,replace,string,count)
- find - (Required) Specify the value to found.
- replace - (Required) Specify the value to replace.
- string - (optional) Specifies the string to search.
- count - (optional) A variable that counts the number of replacement.
Example
<?php echo str_ireplace("Morning","Evening","Hello Good Morning!"); ?>
Output
Hello Good Evening!
Example
<?php $find = array("HELLO","GOOD","MORNING"); $replace = array("A"); $arr = array("Hello","GOOD","MORNING","!"); print_r(str_ireplace($find,$replace,$arr)); ?>
Output
Array ( [0] => A [1] => [2] => [3] => ! )