Current Location: Home> Function Categories> str_replace

str_replace

Substring replacement
Name:str_replace
Category:String
Programming Language:php
One-line Description:Replace some characters in the string (case sensitive).

Definition and usage

str_replace() function replaces some characters in the string with other characters (case sensitive).

This function must follow the following rules:

  • If the searched string is an array, then it returns the array.
  • If the searched string is an array, it will look up and replace each element in the array.
  • If the array needs to be searched and replaced at the same time, and the number of elements that need to be replaced is less than the number of elements found, then the excess elements will be replaced with an empty string
  • If the search is an array and the replacement is a string, the replacement string will work for all the found values.

Note: This function is case sensitive. Please use str_ireplace() function to perform case-insensitive searches.

Note: This function is binary safe.

grammar

 str_replace ( find , replace , string , count )
parameter describe
Find Required. Specifies the value to be found.
replace Required. Specifies the value that replaces the value in find .
string Required. Specifies the string being searched.
count Optional. A variable that counts the replacement number.
Similar Functions
Popular Articles