How does the use of array_filter() function in PHP help in this context?

Issue: We have an array containing both numeric and string values, and we want to filter out only the numeric values from the array. Solution: We can use the array_filter() function in PHP to iterate over the array and apply a callback function to filter out the numeric values. PHP code snippet:

$array = [1, 'apple', 2, 'banana', 3, 'cherry'];
$numericValues = array_filter($array, function($value) {
    return is_numeric($value);
});

print_r($numericValues);