Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP str_ireplace() Function

PHP str_ireplace() Function

PHP String Reference Manual PHP String Reference Manual

Example

Replace the characters "WORLD" (case-insensitive) in the string "Hello world!" with "Peter":

Run Example »


Definition and Usage

The str_ireplace() function replaces some characters in a string (case-insensitive).

This function must follow these rules:

**Note:** This function is case-insensitive. Use the str_replace() function to perform a case-sensitive search.

**Note:** This function is binary-safe.


Syntax

str_ireplace(

find,replace,string,count

)

Parameters Description
find Required. Specifies the value to find.
replace Required. Specifies the replacement find value.
string Required. Specifies the string to be searched.
count Optional. A variable that counts the number of replacements.

Technical Details

Return Value: Returns the string or array with replacement values.
PHP Version: 5+
Changelog: In PHP 5.0, the count parameter was added.

More examples

Example 1

Use the str_ireplace() function with arrays and a count variable:

Run Example »

Example 2

Use the str_ireplace() function with fewer elements to replace than elements found:

Run Example »


PHP String Reference Manual PHP String Reference Manual