title: I need to implement the function which accepts color as a string parameter and return it as a json_encode
body: <p>I want to get the function that can accept a string parameter and return it to json format.
  for example if i call $ballcolor->getBall("orange");
  then the output// should be:
  { "color":"orange", "ball": ["basketball"]}</p>
  
  <p>and if a call does not have any color for that ball:
  { "color":"black", "ball": []}</p>
  
  <pre><code>class BallColor
      {
        private $ballcolor;
  
        function BallColor($ballcolor)
        {
          $this-&gt;ballcolor = $ballcolor;
        }
  
        public function getBall($color)
        {
  
          return NULL;
  
        }
      }
  
      $ballcolor = new BallColor(array(
          "orange" =&gt; array("basketball"),
          "white" =&gt; array("football")
      ));
  
      echo $ballcolor-&gt;getBall("orange");
      echo "\n";
      echo $ballcolor-&gt;getBall("black");
  </code></pre>