2022-02-19 21:40:56 +01:00
|
|
|
<?php
|
2022-03-01 17:28:37 +01:00
|
|
|
function definition_results($query, $response)
|
2022-02-19 21:40:56 +01:00
|
|
|
{
|
2022-03-01 17:28:37 +01:00
|
|
|
require "config.php";
|
|
|
|
require_once "misc/tools.php";
|
2022-02-19 21:40:56 +01:00
|
|
|
|
2022-03-01 17:28:37 +01:00
|
|
|
$split_query = explode(" ", $query);
|
2022-02-19 21:40:56 +01: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-03-03 10:32:46 +01:00
|
|
|
$source = "https://en.wikipedia.org/wiki/$query";
|
|
|
|
return array(
|
|
|
|
"special_response" => array(
|
|
|
|
"response" => $definition,
|
|
|
|
"source" => $source
|
|
|
|
)
|
|
|
|
);
|
2022-02-19 21:40:56 +01:00
|
|
|
}
|
2022-03-01 17:28:37 +01:00
|
|
|
|
2022-02-19 21:40:56 +01:00
|
|
|
}
|
|
|
|
?>
|