wpseek.com
WordPress开发者和主题制作者的搜索引擎



_deep_replace › WordPress Function

Since2.8.1
已弃用n/a
_deep_replace ( $search, $subject )
访问:
  • private
参数: (2)
  • (string|array) $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
    Required: Yes
  • (string) $subject The string being searched and replaced on, otherwise known as the haystack.
    Required: Yes
返回:
  • (string) The string with the replaced values.
定义在:
文档:

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


源码

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

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

	return $subject;
}