str_ireplace
str_ireplace
Case-insensitive version of str_replace
**str_ireplace** $search $replace $subject int $count
This function returns a string or an array with all occurrences of
in
(ignoring case) replaced with the given
value.
search``subject``replace
To replace text based on a pattern rather than a fixed string,
use with the
.
preg_replace``ipattern modifier
If and are
arrays, then takes a value from each
array and uses them to search and replace on
. If has fewer
values than , then an empty string is used for
the rest of replacement values. If is an
array and is a string, then this replacement
string is used for every value of . The
converse would not make sense, though.
search``replace``str_ireplace``subject``replace``search``search``replace``search
If or
are arrays, their elements are processed first to last.
search``replace
search
The value being searched for, otherwise known as the
. An array may be used to designate
multiple needles.
needle
replace
The replacement value that replaces found
values. An array may be used to designate multiple replacements.
search
subject
The string or array being searched and replaced on,
otherwise known as the .
haystack
If is an array, then the search and
replace is performed with every entry of
, and the return value is an array as
well.
`subject``subject`
countIf passed, this will be set to the number of replacements performed.
Returns a string or an array of replacements.
Voorbeeld: example
<?php
$bodytag = str_ireplace("%body%", "black", "<body text=%BODY%>");
echo $bodytag; // <body text=black>
?>
Let op: > ### Replacement order gotcha
Because replaces left to right, it might replace a previously inserted value when doing multiple replacements. Example #2 in the documentation demonstrates how this may affect you in practice.
str_ireplace``str_replace
str_replace``preg_replace``strtr