protected function filterOutArrayValues($values = null, \Closure $filter = null, $preserveKeys = false)
    {
        $data = [];

        if (is_array($values) && count($values))
        {
            foreach ($values as $key => $value)
            {
                $value = trim($value);

                if (!empty($value))
                {
                    if (is_callable($filter) && $filter($value))
                    {
                        $data[$key] = $value;
                    }
                }
            }

            if (!$preserveKeys)
            {
                $data = array_values($data);
            }
        }

        return $data;
    }
protected function filterOutArrayValues($values = null, \Closure $filter = null, $preserveKeys = false)
    {
        $data = [];

        if (is_array($values) && count($values))
        {
            foreach ($values as $key => $value)
            {
                $value = trim($value);

                if (!empty($value))
                {
                    if (is_callable($filter) && $filter($value))
                    {
                        $data[$key] = $value;
                    }
                }
            }

            if (!$preserveKeys)
            {
                $data = array_values($data);
            }
        }

        return $data;
    }
protected function filterOutArrayValues ( $ values = null , \ Closure $ filter = null , $ preserveKeys = false ) { $ data = [ ] ; if ( is_array ( $ values ) && count ( $ values ) ) { foreach ( $ values as $ key => $ value ) { $ value = trim ( $ value ) ; if ( ! empty ( $ value ) ) { if ( is_callable ( $ filter ) && $ filter ( $ value ) ) { $ data [ $ key ] = $ value ; } } } if ( ! $ preserveKeys ) { $ data = array_values ( $ data ) ; } } return $ data ; }
Filters out array values by using a custom filter

@param array|string|null $values
@param callable|\Closure $filter
@param bool              $preserveKeys

@return array
Filters out array values by using a custom filter