Page MenuHomePhorge

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$listSome list of arrays.
scalar|null$indexDetermines 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_indexDetermines 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
dictA dictionary with keys and values derived according to whatever you passed for `$index` and `$key_index`.