PHP

PHP Menu

PHP

str_ireplace() Function - Definition, Syntax, Parameters, Examples

Definition

The str_ireplace() function replaces some characters with some other characters in a string.

Function rules:

  • If the string to be searched is an array, it returns an array
  • If the string to be searched is an array, find and replace is performed with every array element
  • If both find and replace are arrays, and replace has fewer elements than find, an empty string will be used as replace
  • If find is an array and replace is a string, the replace string will be used for every find value

Syntax

str_ireplace(find, replace, string, count)

Parameters

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

Example

<?php
echo str_ireplace("Hello", "Welcome", "Hello to PHP!");

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods