Can a custom function be created to achieve the exclusion of certain values from the min() function in PHP?

To achieve the exclusion of certain values from the min() function in PHP, you can create a custom function that filters out the values you want to exclude before passing them to the min() function. This custom function can take an array of values and an array of values to exclude, then remove the excluded values before finding the minimum value.

function custom_min($values, $exclude) {
    $filtered_values = array_diff($values, $exclude);
    return min($filtered_values);
}

// Example usage
$values = [1, 2, 3, 4, 5];
$exclude = [2, 4];
echo custom_min($values, $exclude); // Output: 1