wp_list_pluck
函数
wp_list_pluck ( $list, $field, $index_key = null )
- 参数
-
-
(array)
$list
List of objects or arrays.- Required: 是
-
(int|string)
$field
Field from the object to place instead of the entire object.- Required: 是
-
(int|string)
$index_key
Optional. Field from the object to use as keys for the new array. Default null.- Required: 否
- Default: null
-
(array)
- 返回值
-
- (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.
- 定义位置
-
-
wp-includes/functions.php
, line 5188
-
wp-includes/functions.php
- 引入
- 3.1.0
- 弃用
- –
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.
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 ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。