_deep_replace

函数
_deep_replace ( $search, $subject )
Access
Private
参数
  • (string|array) $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
    Required:
  • (string) $subject The string being searched and replaced on, otherwise known as the haystack.
    Required:
返回值
  • (string) The string with the replaced values.
定义位置
相关方法
wp_cache_replaceget_date_templateget_index_templateget_templatedetermine_locale
引入
2.8.1
弃用
-

deep_replace: 递归搜索和替换数组或对象中的值的函数。

执行深度字符串替换操作,确保$search中的值不再存在。

重复替换操作,直到它不再替换任何东西,以便删除”嵌套”的值,例如,$subject = ‘%0%0DDD’, $search =’%0D’, $result =” 而不是’%0%0DD’,因为 str_replace会返回。

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

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

	return $subject;
}

常见问题

FAQs
查看更多 >