In PHP, how do I filter arrays with built-in functions?

In PHP, you can filter arrays using built-in functions such as array_filter(), array_map(), and array_reduce(). These functions allow you to easily manipulate and retrieve data from arrays based on specific conditions or transformations.

Here's an example of using array_filter() to filter an array of numbers:

<?php $numbers = [1, 2, 3, 4, 5, 6]; // Filter out even numbers $evenNumbers = array_filter($numbers, function($number) { return $number % 2 === 0; }); print_r($evenNumbers); ?>

PHP filter arrays array_filter built-in functions