Home / PHP Tips Generated By ChatGPT / Filtering Arrays in PHP Filter elements of an array using a callback function, useful for removing unwanted values. Source Code $numbers = [1, 2, 3, 4, 5, 6]; $even = array_filter($numbers, function($n) { return ($n % 2) == 0; }); print_r($even);