wp_list_pluck() – Plucks a certain field out of each object or array in an array.
You appear to be a bot. Output may be restricted
Description
Plucks a certain field out of each object or array in an array.
This has the same functionality and prototype of array_column() (PHP 5.5) but also supports objects.
Usage
$array = wp_list_pluck( $list, $field, $index_key );
Parameters
- $list
- ( array ) required – List of objects or arrays.
- $field
- ( int|string ) required – Field from the object to place instead of the entire object.
- $index_key
- ( int|string ) optional – Optional. Field from the object to use as keys for the new array. Default null.
Returns
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.
Source
File name: wordpress/wp-includes/functions.php
Lines:
function wp_list_pluck( $list, $field, $index_key = null ) { if ( ! is_array( $list ) ) { return array(); } $util = new WP_List_Util( $list ); return $util->pluck( $field, $index_key ); }