Home > PHP > Function > Strings > Replacement order gotcha()

Replacement order gotcha()

Replacement order gotcha - Replace all occurrences of the search string with the replacement string

Syntax

mixed Replacement order gotcha (mixed $search, mixed $replace, mixed $subject, int &$count)

Arguments

  • search - The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
  • replace - The replacement value that replaces found search values. An array may be used to designate multiple replacements.
  • subject - The string or array being searched and replaced on, otherwise known as the haystack. If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.
  • count - Note: If passed, this will hold the number of matched and replaced needles.

Description

This function returns a string or an array with all occurrences of search in subject replaced with the given replace value.

Version

PHP 4, 5

Return value

This function returns a string or an array with the replaced values.