아래 함수에서 $ matches를 초기화하여 주석 처리 된 행에 정의되지 않은 인덱스가 표시되지 않게하려면 어떻게해야합니까?정의되지 않은 오프셋 : 0 preg_match에서 오류가 발생했습니다.
function save_rseo_nofollow($content) {
$my_folder = get_option('rseo_nofollow_folder');
preg_match_all('~<a.*>~isU',$content["post_content"],$matches);
for ($i = 0; $i <= sizeof($matches[0]); $i++){
if (!preg_match('~nofollow~is',$matches[0][$i]) //ERROR UNDEFINED OFFSET HERE!
&& (preg_match('~' . $my_folder . '~', $matches[0][$i])
|| !preg_match('~'.get_bloginfo('url').'~',$matches[0][$i]))){
$result = trim($matches[0][$i],">");
$result .= ' rel="nofollow">';
$content["post_content"] = str_replace($matches[0][$i], $result, $content["post_content"]);
}
}
return $content;
}
@ Scott B : '$ i'가 ** loop **에 정의 되었기 때문에 배치가 작동하지 않습니다. – Shikiryu
네, 그걸 잡아 내 코멘트를 삭제했습니다. 당신은 저를 펀치에 이겼습니다. 도움을 청합니다. 지금 나는 다른 질문에서 물어볼 동일한 기능에 또 다른 문제가있다 :) –