Documentation

arrayFunctions.php

Table of Contents

array_pluck()  : mixed
Remove a value from array, return the value and reduce the array size by one.
array_kpluck()  : mixed
Remove a value from array, searching by key, return the value and reduce the array size by one.

Functions

array_pluck()

Remove a value from array, return the value and reduce the array size by one.

array_pluck(array<string|int, mixed> &$arr, string $search) : mixed
$arr = ['a', 'b', 'c'];
echo array_pluck($arr, 'b'); // 'b'
var_export($arr); // ['a', 'c']
Parameters
$arr : array<string|int, mixed>
$search : string

value

Return values
mixed

array_kpluck()

Remove a value from array, searching by key, return the value and reduce the array size by one.

array_kpluck(array<string|int, mixed> &$arr, string $search) : mixed
$arr = ['a' => 'foo', 'b' => 'bar', 'c' => 'baz'];
echo array_kpluck($arr, 'b'); // 'bar'
var_export($arr); // ['a' => 'foo', 'c' => 'baz']
Parameters
$arr : array<string|int, mixed>
$search : string

key value

Return values
mixed

Search results