So, I have this function that I am trying to run that looks like this:
function getValue($root, $i = null)
{
if(isset($root[$i]['Hello'])
{
return $root[$i]['Hello'];
}
elseif(isset($root['Hello'])
{
return $root['Hello'];
}
else
{
return '';
}
}
I do not want [$i]
to be there if it is null. How could I go about doing this without writing a lot of code that is basically repetitive?