How can the empty values and values with zero be excluded from the min() function in PHP?

To exclude empty values and values with zero from the min() function in PHP, you can use array_filter() to remove these values from the array before passing it to the min() function. This way, only non-empty and non-zero values will be considered when finding the minimum value.

$values = [5, 0, 3, '', 8, null, 2];
$filtered_values = array_filter($values, function($value) {
    return $value !== '' && $value !== 0;
});

$min_value = min($filtered_values);
echo $min_value;