is_numeric($flags) &&
$flags !== 0
) ||
is_array($flags) &&
$flags !==
[] ) ) { if (is_array($data)) { // Iterate over array and append filter and flags
array_walk_recursive($data,
static function D&
$val) use ($filter,
$flags) { $valType =
gettype($val);
$val =
filter_var($val,
$filter,
$flags);
if (in_array($valType,
['int', 'integer', 'float', 'double', 'bool', 'boolean'
], true
) &&
$val !== false
) { settype($val,
$valType);
} });
} else { $dataType =
gettype($data);
$data =
filter_var($data,
$filter,
$flags);
if (in_array($dataType,
['int', 'integer', 'float', 'double', 'bool', 'boolean'
], true
) &&
$data !== false
) { settype($data,
$dataType);
} } }