I am using this shorthand in a function to set a variable to NULL if it is not set. How can I simply not set it?
function createArray($rows){
$array = array();
$array['id'] = isset($rows['UnitId']) ? $rows['UnitId'] : NULL ;
}
I am using this shorthand in a function to set a variable to NULL if it is not set. How can I simply not set it?
function createArray($rows){
$array = array();
$array['id'] = isset($rows['UnitId']) ? $rows['UnitId'] : NULL ;
}
Just don't set it in the first place
function createArray($rows){
$array = array();
if(isset($rows['UnitId'])) $array['id'] = $rows['UnitId'];
}