WordPress at a glance
function is not described

_deep_replace() WP 2.8.1

Perform 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 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

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.


String. The string with the replaced values.


_deep_replace( $search, $subject );
$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.


Since 2.8.1 Introduced.

Code of _deep_replace() WP 5.7.2

function _deep_replace( $search, $subject ) {
	$subject = (string) $subject;

	$count = 1;
	while ( $count ) {
		$subject = str_replace( $search, '', $subject, $count );

	return $subject;