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"]}
and if a call does not have any color for that ball: { "color":"black", "ball": []}
class BallColor
{
private $ballcolor;
function BallColor($ballcolor)
{
$this->ballcolor = $ballcolor;
}
public function getBall($color)
{
return NULL;
}
}
$ballcolor = new BallColor(array(
"orange" => array("basketball"),
"white" => array("football")
));
echo $ballcolor->getBall("orange");
echo "
";
echo $ballcolor->getBall("black");