Definition:
function wp_list_pluck( $list, $field ) {}
Pluck a certain field out of each object in a list.
Parameters
- array $list: A list of objects or arrays
- int|string $field: A field from the object to place instead of the entire object
Source code
function wp_list_pluck( $list, $field ) {
foreach ( $list as $key => $value ) {
if ( is_object( $value ) )
$list[ $key ] = $value->$field;
else
$list[ $key ] = $value[ $field ];
}
return $list;
}
10847

February 24, 2011 


No comments yet... Be the first to leave a reply!