(.*)\<\/title\>/", $contents, $page_title); //getting page title if (preg_match("#\(.*)\<\/body\>#si", $contents, $body_content)) { //getting content only between 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("/\/", $contents, $res)) { $final_result[$file_count][$template_tokens[$j]] = $res[1]; } } if ($found && !empty($found)) { for ($z = 0; $z < count($found[0]); $z++) { $pos = $found[0][$z][1]; $side_chars = SIDE_CHARS; if ($pos < SIDE_CHARS) { $side_chars = $pos; if (isset($_GET['liveSearch']) and $_GET['liveSearch'] != "") { $pos_end = SIDE_CHARS + $search_term_length + 15; } else { $pos_end = SIDE_CHARS * 9 + $search_term_length; } } else { if (isset($_GET['liveSearch']) and $_GET['liveSearch'] != "") { $pos_end = SIDE_CHARS + $search_term_length + 15; } else { $pos_end = SIDE_CHARS * 9 + $search_term_length; } } $pos_start = $pos - $side_chars; $str = substr($clean_content, $pos_start, $pos_end); $result = preg_replace('#' . $search_term . '#ui', '\0', $str); //$result = preg_replace('#'.$search_term.'#ui', ''.$search_term.'', $str); $final_result[$file_count]['search_result'][] = $result; } } else { $final_result[$file_count]['search_result'][] = ''; } $file_count++; } if ($file_count > 0) { //Sort final result foreach ($final_result as $key => $row) { $search_result[$key] = $row['search_result']; } array_multisort($search_result, SORT_DESC, $final_result); } ?>
0 and isset($_GET['liveSearch']) and $_GET['liveSearch'] != "") { echo "
Quick Results
"; } ?>
    = $search_live_count) { } else { ?>
  1. No results found for "' . $search_term . '"
1) { $result = end($parts); } return $result; } function strpos_recursive($haystack, $needle, $offset = 0, &$results = array()) { $offset = stripos($haystack, $needle, $offset); if ($offset === false) { return $results; } else { $pattern = '/' . $needle . '/ui'; preg_match_all($pattern, $haystack, $results, PREG_OFFSET_CAPTURE); return $results; } } ?>