The array_filter function filters the elements of an array using a callback function

    
    // returns whether the input integer is even
    function even($var)
    {
        return !($var & 1);
    }

    $array = [6, 7, 8, 9, 10, 11, 12];

    $even = array_filter($array, "even");

    print_r($even);

    // Array
    // (
    //  [0] => 6
    //  [1] => 8
    //  [2] => 10
    //  [3] => 12
    // )