2022-02-19 15:40:56 -05:00
|
|
|
<?php
|
2022-03-01 11:28:37 -05:00
|
|
|
function definition_results($query, $response)
|
2022-03-11 04:04:36 -05:00
|
|
|
{
|
2022-03-01 11:28:37 -05:00
|
|
|
$split_query = explode(" ", $query);
|
2022-02-19 15:40:56 -05: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 05:22:26 -04:00
|
|
|
$source = "https://dictionaryapi.dev";
|
2022-03-03 04:32:46 -05:00
|
|
|
return array(
|
|
|
|
"special_response" => array(
|
2022-05-15 04:34:46 -04:00
|
|
|
"response" => htmlspecialchars($definition),
|
2022-03-03 04:32:46 -05:00
|
|
|
"source" => $source
|
|
|
|
)
|
|
|
|
);
|
2022-02-19 15:40:56 -05:00
|
|
|
}
|
2022-03-01 11:28:37 -05:00
|
|
|
|
2022-02-19 15:40:56 -05:00
|
|
|
}
|
2022-05-15 04:34:46 -04:00
|
|
|
?>
|