[wp-trac] [WordPress Trac] #57136: wp_list_pluck's key argument not working correctly when its zero

WordPress Trac noreply at wordpress.org
Thu Nov 17 16:36:32 UTC 2022


#57136: wp_list_pluck's key argument not working correctly when its zero
--------------------------+-----------------------------
 Reporter:  dgwatkins     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 This is better explained with an example:
 ```
 wp> var_dump( wp_list_pluck( [ [ 'key1', 'val1' ], [ 'key2', 'val2' ] ],
 1, 0 ));
 array(2) {
   [0]=>
   string(4) "val1"
   [1]=>
   string(4) "val2"
 }
 ```

 See the missing key?

 If we try with array_column it works correctly:
 ```
 wp> var_dump( array_column( [ [ 'key1', 'val1' ], [ 'key2', 'val2' ] ], 1,
 0 ));
 array(2) {
   ["key1"]=>
   string(4) "val1"
   ["key2"]=>
   string(4) "val2"
 }
 ```

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57136>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list