I have this array:
$array1 = [
"a" => 1,
"b" => 2,
"c" => 3
];
Sometimes, in this array, the keys a and b are set to null, so the array is like the following:
$array2 = [
"a" => null,
"b" => null,
"c" => null
];
How can i get a new array with only keys a and b if they're not null, otherwise an empty array?
This should be the result:
$newArray1 = [
"a" => 1,
"b" => 2
];
$newArray2 = [];