Instead of doing:
$name = !empty($json['name']) ? $json['name'] : null;
just do:
$name = burntCheck($json['name']);
And instead of:
$name = !empty($json['name']) ? $json['name'] : 'Unknown;
do:
$name = burntCheck($json['name'], 'Unknown');
function burntCheck(&$valueToCheck, $default = null) | |
{ | |
if (!empty($valueToCheck)) { | |
return $valueToCheck; | |
} | |
else { | |
return $default; | |
} | |
} |
Instead of doing:
$name = !empty($json['name']) ? $json['name'] : null;
just do:
$name = burntCheck($json['name']);
And instead of:
$name = !empty($json['name']) ? $json['name'] : 'Unknown;
do:
$name = burntCheck($json['name'], 'Unknown');