How can PHP functions like array_filter be used to manipulate arrays based on specific criteria?
To manipulate arrays based on specific criteria, PHP functions like array_filter can be used. This function filters an array using a callback function, which determines whether each element should be included in the resulting array based on the criteria specified in the callback function.
// Example of using array_filter to filter an array based on specific criteria
$numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// Filter out even numbers
$filteredNumbers = array_filter($numbers, function($num) {
return $num % 2 != 0;
});
print_r($filteredNumbers);