array_intersect

Supported Versions: PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8
Computes the intersection of arrays
<?php array_intersect(array $array, array ...$arrays): array
<?php         if ($selected = $this->resource->selectedQueryColumns()) {

            $diff = array_intersect($selected, $fields);

            $fields = empty($diff) ? $fields : $diff;

        }
<?php             $model = $this->builder->getModel();

            $schema = $model->getConnection()->getSchemaBuilder()->getColumnListing($model->getTable());

            $selected = array_intersect($schema, $columns);

        }



        return empty($selected) ? ['*'] : $selected;