<?php
// Surprise surprise! When the 2nd array param of array_diff() contains an elemant with value false,
// the result will no longer contain null values.
function myIsset($value)
{
return isset($value);
}
$arrayWithTrueValue = array(
'null1' => null,
'null2' => null,
'bool' => true,
);
$filteredArray = array_filter($arrayWithTrueValue, 'myIsset');
echo "$arrayWithTrueValue has three elements..\n";
var_dump($arrayWithTrueValue);
echo "$filteredArray has one element (only isset(true) === true)\n";
var_dump($filteredArray);
echo "so the difference is an array with two elements..\n";
var_dump(array_diff($arrayWithTrueValue, $filteredArray));
$arrayWithFalseValue = $arrayWithTrueValue;
$arrayWithFalseValue['bool'] = false;
$filteredArrayWithOnlyFalse = array_filter($arrayWithFalseValue, 'myIsset');
var_dump($arrayWithFalseValue, $filteredArrayWithOnlyFalse, array_diff($arrayWithFalseValue, $filteredArrayWithOnlyFalse));