{"id":17191943,"url":"https://github.com/danielsdeboer/array-map-keys","last_synced_at":"2025-04-13T20:07:17.595Z","repository":{"id":62489883,"uuid":"112014008","full_name":"danielsdeboer/array-map-keys","owner":"danielsdeboer","description":"Map over an array with access to keys","archived":false,"fork":false,"pushed_at":"2017-11-25T16:18:38.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-14T12:52:48.153Z","etag":null,"topics":["arrays","keys","map","php","php7"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielsdeboer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-25T15:30:15.000Z","updated_at":"2023-03-27T19:41:51.000Z","dependencies_parsed_at":"2022-11-02T11:16:08.579Z","dependency_job_id":null,"html_url":"https://github.com/danielsdeboer/array-map-keys","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsdeboer%2Farray-map-keys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsdeboer%2Farray-map-keys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsdeboer%2Farray-map-keys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsdeboer%2Farray-map-keys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielsdeboer","download_url":"https://codeload.github.com/danielsdeboer/array-map-keys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219847401,"owners_count":16556403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrays","keys","map","php","php7"],"created_at":"2024-10-15T01:27:48.678Z","updated_at":"2024-10-15T01:27:48.760Z","avatar_url":"https://github.com/danielsdeboer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/aviator/array-map-keys/v/stable)](https://packagist.org/packages/aviator/array-map-keys)\n[![License](https://poser.pugx.org/aviator/array-map-keys/license)](https://packagist.org/packages/aviator/array-map-keys)\n[![Build Status](https://travis-ci.org/danielsdeboer/array-map-keys.svg?branch=master)](https://travis-ci.org/danielsdeboer/array-map-keys)\n\n## Overview\n\nPHP's `array_map()` function doesn't allow associative array key mutation. This package provides a function, `array_map_keys()`, which does.\n\nThe function iterates over an array and mutates each array item with the provided callback.\n\n## Installation\n\nVia Composer:\n```\ncomposer require aviator/array-map-keys\n```\n\n## Testing\n\nVia Composer:\n```\ncomposer test\n```\n\n## Usage\n\nAn array:\n\n```php\n$input = [\n    [\n        'company' =\u003e 'Aviator Creative',\n        'owner' =\u003e 'Daniel Deboer',\n        'email' =\u003e 'daniel.s.deboer@gmail.com',\n    ],\n    [\n        'company' =\u003e 'Widget Makers',\n        'owner' =\u003e 'Jane Doe',\n        'email' =\u003e 'jane@widgets.com',\n    ],\n];\n```\n\nA callback:\n\n```php\n$callback = function ($key, $value) {\n    return [\n        $value['owner'] =\u003e $value['email'];\n    ];\n};\n```\n\nThe `array_map_keys` function:\n\n```php\n$results = array_map_keys($input, $callback);\n```\n\nThe output:\n\n```php\necho $results;\n\n/*\n[\n    'Daniel Deboer' =\u003e 'daniel.s.deboer@gmail.com',\n    'Jane Doe' =\u003e 'jane@widgets.com',\n]\n*/\n```\n\n## Other Stuff\n\n### License\n\nThis package is licensed with the [MIT License (MIT)](LICENSE.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsdeboer%2Farray-map-keys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielsdeboer%2Farray-map-keys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsdeboer%2Farray-map-keys/lists"}