値の配列のいずれかが文字列に存在するかどうかを確認する方法を探していましたが、PHP にはこれを行うネイティブな方法がないように思われるため、以下を思いつきました。
私の質問 - これはかなり非効率的であるため、これを行うためのより良い方法はありますか? ありがとう。
$match_found = false;
$referer = wp_get_referer();
$valid_referers = array(
'dd-options',
'dd-options-footer',
'dd-options-offices'
);
/** Loop through all referers looking for a match */
foreach($valid_referers as $string) :
$referer_valid = strstr($referer, $string);
if($referer_valid !== false) :
$match_found = true;
continue;
endif;
endforeach;
/** If there were no matches, exit the function */
if(!$match_found) :
return false;
endif;