array_filter

Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Filters elements of an array using a callback function
<?php array_filter(array $array, ?callable $callback = null, int $mode = 0): array
<?php     {

        $groups = $this->raw();



        $groups->put($group->handle(), array_filter([

            'title' => $group->title(),

            'roles' => $group->roles()->map->handle()->values()->all(),

        ]));



        if ($group->handle() !== $group->originalHandle()) {

            $groups->forget($group->originalHandle());
<?php             storage_path('statamic'),

        ];



        foreach (array_filter($gitkeeps) as $dir) {

            if (! File::exists($gitkeep = $dir.'/.gitkeep')) {

                File::put($gitkeep, '');

                $this->info("Created the <comment>[$dir]</comment> directory.");
<?php             }

        }



        foreach (array_filter($gitignores) as $dir) {

            if (! File::exists($gitignore = $dir.'/.gitignore')) {

                File::put($gitignore, "*\n!.gitignore");

                $this->info("Created the <comment>[$dir]</comment> directory.");
<?php             $contents = $this->addEnsuredFieldsToContents($contents, $this->ensuredFields);

        }



        return array_filter(

            array_merge([

                'hide' => $this->hidden,

                'order' => $this->order,

            ], $contents)

        );

    }



    private function addEnsuredFieldsToContents($contents, $ensuredFields)
<?php     private static function importSectionField(array $submitted)

    {

        return array_filter([

            'import' => $submitted['fieldset'],

            'prefix' => $submitted['prefix'] ?? null,

        ]);

    }



    private static function inlineSectionField(array $submitted)
<?php             unset($field['localizable']);

        }



        return array_filter([

            'handle' => $submitted['handle'],

            'field' => $field,

        ]);

    }



    private static function referenceSectionField(array $submitted)
<?php     {

        $config = Arr::removeNullValues(array_only($submitted['config'], $submitted['config_overrides']));



        return array_filter([

            'handle' => $submitted['handle'],

            'field' => $submitted['field_reference'],

            'config' => $config,

        ]);

    }



    public static function toVue($field): array
<?php         $values = $values->all();



        if ($entry->hasStructure()) {

            $values['parent'] = array_filter([optional($entry->parent())->id()]);

        }



        if ($entry->collection()->dated()) {
<?php         $blueprint

            ->setHidden($request->hidden)

            ->setContents(array_filter([

                'title' => $request->title,

                'sections' => $sections,

            ]));



        return $blueprint;

    }
<?php     private function buildAttributesFromParameters($params, $delimiter = ':')

    {

        if (empty(array_filter($params))) {

            return [];

        }
<?php     public static function assoc($array)

    {

        return (bool) count(array_filter(array_keys($array), 'is_string'));

    }
<?php     public static function removeNullValues($data)

    {

        return array_filter($data, function ($item) {

            return is_array($item)

                ? ! empty($item)

                : ! in_array($item, [null, ''], true);

        });

    }
<?php     protected function filterByFields($entry)

    {

        $fields = array_filter(explode('|', $this->params->get('fields')));



        $fields = $fields

            ? $entry->toAugmentedArray($fields)
<?php             [$taxonomy, $modifier] = array_pad(explode(':', $taxonomy), 2, 'any');



            if (is_string($values)) {

                $values = array_filter(explode('|', $values));

            }



            if (is_null($values) || (is_iterable($values) && count($values) === 0)) {
<?php     protected function setMessage()

    {

        $this->message = array_flip(array_filter(get_defined_constants(true)['pcre'], function ($value) {

            return substr($value, -6) === '_ERROR';

        }, ARRAY_FILTER_USE_KEY))[$this->error];

    }



    public function getSolution(): Solution