query = str_replace("_", "-", str_replace("php ", "", $this->query)); return "https://www.php.net/manual/function.".urlencode($this->query); } public function parse_results($response) { $results = array(); $xpath = get_xpath($response); if($xpath) { // Scrape the page $title = $xpath->query("//div/section/div[@class='refentry']/div/h1[@class='refname']")[0]->textContent; if(is_null($title)) return array(); $php_versions = $xpath->query("//div/section/div[@class='refentry']/div/p[@class='verinfo']")[0]->textContent; $purpose = $xpath->query("//div/section/div[@class='refentry']/div/p[@class='refpurpose']")[0]->textContent; $usage = $xpath->query("//div/section/div[@class='refentry']/div[@class='refsect1 description']/div[@class='methodsynopsis dc-description']")[0]->textContent; $response = array ( // Required "title" => sanitize($title), "text" => "
".$php_versions."
".$purpose."
".highlight_string("", 1)."
", "source" => "https://www.php.net/manual/function.".urlencode($this->query) ); return $response; } else { return array( "title" => "Oof...", "text" => "PHP.net didn't provide any answers. Try again later." ); } } } ?>