function ipull($list, $index, $key_index)Arcanist Technical Documentation ()
function ipull($list, $index, $key_index)
Arcanist Technical Documentation ()
Choose an index from a list of arrays. Short for "index pull", this function works just like mpull(), except that it operates on a list of arrays and selects an index from them instead of operating on a list of objects and calling a method on them.
This function simplifies a common type of mapping operation:
$names = array(); foreach ($list as $key => $dict) { $names[$key] = $dict['name']; }
With ipull():
$names = ipull($list, 'name');
See mpull() for more usage examples.
Parameters
list | $list | Some list of arrays. |
scalar|null | $index | Determines which **values** will appear in the result array. Use a scalar to select that index from each array, or null to preserve the arrays unmodified as values. |
scalar|null | $key_index | Determines which **keys** will appear in the result array. Use a scalar to select that index from each array, or null to preserve the array keys. |
Return
dict | A dictionary with keys and values derived according to whatever you passed for `$index` and `$key_index`. |
- Defined
- src/utils/utils.php:262