query);
// [0] = (define|d|mean|meaning)
// [1] = WORD
return "https://api.dictionaryapi.dev/api/v2/entries/en/".$query_terms[1];
}
public function parse_results($response) {
$json_response = json_decode($response, true);
if(!empty($json_response)) {
// Word not found
if (array_key_exists("title", $json_response)) {
return array(
"title" => strip_tags(trim($json_response['title'])),
"text" => strip_tags(trim($json_response['message']))
);
}
// Grab first result if there are multiple
$result = $json_response[0];
$definitions = array_slice($result['meanings'][0]['definitions'], 0, 3);
// Word found
$formatted_response = strip_tags(trim($result['meanings'][0]['partOfSpeech']))."