내 검색 엔진 용 단어의 색인 생성을위한 코드를 작성 중입니다. 같은 뭔가 : 오류 받기 : 정의되지 않은 오프셋
$handle = fopen("http://localhost/ps-friend/index.php", "r");
while($buf = fgets($handle,1024))
{
/* Remove whitespace from beginning and end of string: */
$buf = trim($buf);
/* Try to remove all HTML-tags: */
$buf = strip_tags($buf);
$buf = preg_replace('/&\w;/', '', $buf);
/* Extract all words matching the regexp from the current line: */
preg_match_all("/(\b[\w+]+\b)/",$buf,$words);
/* Loop through all words/occurrences and insert them into the database(Not shown here): */
for($i = 0; $words[$i]; $i++)
{
for($j = 0; $words[$i][$j]; $j++)
{
$cur_word = addslashes(strtolower($words[$i][$j]));
echo $cur_word;
}
}
}
내가 line 24
에 가끔 오류 Notice: Undefined offset: 2 in C:\xampp\htdocs\ps-friend\search.php on line 26
와가 계속 왜 $cur_word
에코
당신은 단순히 정규식이 무언가와 일치한다고 가정하고 반복합니다. –