2022-02-19 12:40:56 -08:00
|
|
|
<?php
|
2022-03-01 08:28:37 -08:00
|
|
|
function definition_results($query, $response)
|
2022-03-11 01:04:36 -08:00
|
|
|
{
|
2022-03-01 08:28:37 -08:00
|
|
|
$split_query = explode(" ", $query);
|
2022-02-19 12:40:56 -08:00
|
|
|
$reversed_split_q = array_reverse($split_query);
|
|
|
|
$word_to_define = $reversed_split_q[1];
|
|
|
|
|
|
|
|
$json_response = json_decode($response, true);
|
|
|
|
|
|
|
|
if (!array_key_exists("title", $json_response))
|
|
|
|
{
|
|
|
|
$definition = $json_response[0]["meanings"][0]["definitions"][0]["definition"];
|
|
|
|
|
2022-04-01 02:22:26 -07:00
|
|
|
$source = "https://dictionaryapi.dev";
|
2022-03-03 01:32:46 -08:00
|
|
|
return array(
|
|
|
|
"special_response" => array(
|
2022-05-15 01:34:46 -07:00
|
|
|
"response" => htmlspecialchars($definition),
|
2022-03-03 01:32:46 -08:00
|
|
|
"source" => $source
|
|
|
|
)
|
|
|
|
);
|
2022-02-19 12:40:56 -08:00
|
|
|
}
|
2022-03-01 08:28:37 -08:00
|
|
|
|
2022-02-19 12:40:56 -08:00
|
|
|
}
|
2022-05-15 01:34:46 -07:00
|
|
|
?>
|