On this page
_deep_replace( string|array $search, string $subject ): string
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Performs a deep string replace operation to ensure the values in $search are no longer present.
Description
Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values e.g. $subject = ‘%0%0%0DDD’, $search =’%0D’, $result =” rather than the ‘%0%0DD’ that str_replace would return
Parameters
$searchstring|array Required-
The value being searched for, otherwise known as the needle.
An array may be used to designate multiple needles. $subjectstring Required-
The string being searched and replaced on, otherwise known as the haystack.
Return
string The string with the replaced values.
Source
File: wp-includes/formatting.php. View all references
function _deep_replace( $search, $subject ) {
$subject = (string) $subject;
$count = 1;
while ( $count ) {
$subject = str_replace( $search, '', $subject, $count );
}
return $subject;
}
Related
Used By
| Used By | Description |
|---|---|
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
| wp_sanitize_redirect() wp-includes/pluggable.php | Sanitizes a URL for use in a redirect. |
Changelog
| Version | Description |
|---|---|
| 2.8.1 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_deep_replace