PHP str_ireplace() Function

PHP str_pad() Function
PHP str_getcsv() Function

what is the syntax of the STR_IREPLACE() function in php?

str_ireplace(find,replace,string,count)
ParameterDescription
findRequired. Specifies the value to find
replaceRequired. Specifies the value to replace the value in find
stringRequired. Specifies the string to be searched
countOptional. A variable that counts the number of replacements
PHP STR_IREPLACE() method

examples of the STR_IREPLACE() function

Example 1. In this example, we replace the characters “WORLD” (case-insensitive) in the string “Hello world!” with “Peter”.

<?php
echo str_ireplace("WORLD","Peter","Hello world!");
?>

Example 2. In this example, we use str_ireplace() with an array and a count variable.

<?php
$arr = array("blue","red","green","yellow");
print_r(str_ireplace("RED","pink",$arr,$i)); // This function is case-insensitive
echo "Replacements: $i";
?>

Example 3. In this example, we use str_ireplace() with fewer elements in replace than find.

<?php
$find = array("HELLO","WORLD");
$replace = array("B");
$arr = array("Hello","world","!");
print_r(str_ireplace($find,$replace,$arr));
?>
PHP str_pad() Function
PHP str_getcsv() Function
en English
X
Scroll to Top