_deep_replace()WP 2.8.1

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

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

Строку. The string with the replaced values.

Использование

_deep_replace( $search, $subject );
$search(строка|массив) (обязательный)
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
$subject(строка) (обязательный)
The string being searched and replaced on, otherwise known as the haystack.

Список изменений

С версии 2.8.1 Введена.

Код _deep_replace() WP 6.5.2

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

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

	return $subject;
}