Alert: 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.

_deep_replace( string|array $search, string $subject ): string

Performs a deep string replace operation to ensure the values in $search are no longer present.


Repeats the replacement operation until it no longer replaces anything to remove "nested" values e.g. $subject = ‘%0%0%0DDD’, $search =’%0D’, $result =” rather than the ‘%0%0DD’ that str_replace would return

Top ↑


$search string|array Required
The value being searched for, otherwise known as the needle.
An array may be used to designate multiple needles.
$subject string Required
The string being searched and replaced on, otherwise known as the haystack.

Top ↑


string The string with the replaced values.

Top ↑


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;

Top ↑


Version Description
2.8.1 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.