WP_List_Util::pluck

SummerySummery

Plucks a certain field out of each object in the list.

Syntax

WP_List_Util::pluck( int|string $field, int|string $index_key = null )

DescriptionDescription

This has the same functionality and prototype of array_column() (PHP 5.5) but also supports objects.

ParametersParameters

$field

(int|string) (Required) Field from the object to place instead of the entire object

$index_key

(int|string) (Optional) Field from the object to use as keys for the new array.

Default value: null

ReturnReturn

(array) Array of found values. If $index_key is set, an array of found values with keys corresponding to $index_key. If $index_key is null, array keys from the original $list will be preserved in the results.

SourceSource

File: wp-includes/class-wp-list-util.php


			

ChangelogChangelog

Changelog
Version Description
4.7.0 Introduced.
Scroll to Top