Return a subset of the array by passing in an array of keys to keep
array_only(array $array, array $keys): array
array
The input array
keys
The keys to keep in the result
Returns a copy of the array with the keys kept and all others discarded.
Example # 1 Example uses of array_only()
print_r(
array_only([
'a' => 1,
'b' => 2
], ['a'])
);
The above example will output:
Array
(
[a] => 1
)