Skip to content

Function to build associative arrays from an input list and two user functions producing keys and values for the output list #164

@gvlasov

Description

@gvlasov

This is a feature request. Something like this:

create_map(
  ['cat', 'bear', 'aardvark'],
  function($element, $index, $collection) {
    return strlen($element);
  }
);
/*
returns [
  'cat'=>3,
  'bear'=>4,
  'aardvark'=>8
];
*/

I'm not sure what that function would be called, I admit that it should have a better name than create_map

Couldn't properly explain what I want in the original post, see a comment below: #164 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions