KaueDrey

Teste

Aug 13th, 2018
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Thesaurus
  4. {
  5.     private $thesaurus;
  6.  
  7.     function Thesaurus($thesaurus)
  8.     {
  9.         $this->thesaurus = $thesaurus;
  10.     }
  11.  
  12.     public function getSynonyms(string $word)
  13.     {
  14.         if($this->thesaurus[$word]) {
  15.             $data = [
  16.                 'word' => $word,
  17.                 'synonyms' => $this->thesaurus[$word]
  18.             ];
  19.  
  20.         } else {
  21.             $data = [
  22.                 'word' => $word,
  23.                 'synonyms' => []
  24.             ];
  25.         }
  26.  
  27.         return json_encode($data);
  28.     }
  29. }
  30.  
  31. $thesaurus = new Thesaurus(
  32.     array
  33.         (
  34.             "buy" => array("purchase"),
  35.             "big" => array("great", "large")
  36.         ));
  37.  
  38. echo $thesaurus->getSynonyms("big");
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×