Good afternoon people. I'm to ask some help about PHP error.I've this code that reports an error, but I don't understand what I can modify.
Error reported is:
Notice: Undefined offset: 1 in /Applications/XAMPP/xamppfiles/htdocs/bat/rd-search.php on line 53 that is this string of code:
$final_result[$file_count]['page_title'][] = $page_title[1];
the code is:
$contents = file_get_contents($file);
preg_match("/\<title\>(.*)\<\/title\>/", $contents, $page_title); //getting page title
if (preg_match("#\<body.*\>(.*)\<\/body\>#si", $contents, $body_content)) { //getting content only between <body></body> tags
$clean_content = strip_tags($body_content[0]); //remove html tags
$clean_content = preg_replace('/\s+/', ' ', $clean_content); //remove duplicate whitespaces, carriage returns, tabs, etc
$found = strpos_recursive(mb_strtolower($clean_content, 'UTF-8'), $search_term);
$final_result[$file_count]['page_title'][] = $page_title[1];
$final_result[$file_count]['file_name'][] = preg_replace("/^.{3}/", "\\1", $file);
}
for ($j = 0; $j < count($template_tokens); $j++) {
if (preg_match("/\<meta\s+name=[\'|\"]" . $template_tokens[$j] . "[\'|\"]\s+content=[\'|\"](.*)[\'|\"]\>/", $contents, $res)) {
$final_result[$file_count][$template_tokens[$j]] = $res[1];
}
}
Thanks very much