_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會返回。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _deep_replace( $search, $subject ) {
$subject = (string) $subject;
$count = 1;
while ( $count ) {
$subject = str_replace( $search, '', $subject, $count );
}
return $subject;
}
function _deep_replace( $search, $subject ) { $subject = (string) $subject; $count = 1; while ( $count ) { $subject = str_replace( $search, '', $subject, $count ); } return $subject; }
function _deep_replace( $search, $subject ) {
	$subject = (string) $subject;

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

	return $subject;
}

常見問題

FAQs
檢視更多 >