PHPackages                             alaa/array-key-map - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alaa/array-key-map

AbandonedArchivedPhp-library[Utility &amp; Helpers](/categories/utility)

alaa/array-key-map
==================

1.0.0(7y ago)018MITPHPPHP &gt;=7.0

Since Jun 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/alaa-almaliki/array-key-map)[ Packagist](https://packagist.org/packages/alaa/array-key-map)[ Docs](https://gitlab.com/alaa-almaliki/array-key-map)[ RSS](/packages/alaa-array-key-map/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Array Key Map
=============

[](#array-key-map)

Ever wanted to rename array keys to suit your requirements but it will take many lines that results in an ugly code? Here is a clean way to do it

Installation
============

[](#installation)

By Composer: `composer require alaa/array-key-map`

Documentation
=============

[](#documentation)

There are three types you can use to map your array keys against the keys you want your array to be mapped with.

1. Simply using an array to map keys
------------------------------------

[](#1-simply-using-an-array-to-map-keys)

Example

```
$array = [
    'First Name' => 'John',
    'Last Name' => 'Doe',
    'email' => 'john.doe@example.com',
    'Field Experience' => 10,
    'Current Job' => 'Software Engineer',
    'Department' => 'Web Development'
];

$mappedKeys = [
    'First Name' => 'first_name',
    'Last Name' => 'last_name',
    'Field Experience' => 'experience',
    'Current Job' => 'job',
    'Department' => 'department'
];

$sourceArray = new \ArrayKey\Map\Source\SourceArray($mappedKeys);
$source = new \ArrayKey\Map\Source($sourceArray, $array);
print_r($source->getSourceArray());
//result:
Array
(
    [First Name] => John
    [Last Name] => Doe
    [email] => john.doe@example.com
    [Field Experience] => 10
    [Current Job] => Software Engineer
    [Department] => Web Development
)

print_r($source->getMappedArray());
//result:
Array
(
    [first_name] => John
    [last_name] => Doe
    [email] => john.doe@example.com
    [experience] => 10
    [job] => Software Engineer
    [department] => Web Development
)

```

2. Csv Mapping to map array keys
--------------------------------

[](#2-csv-mapping-to-map-array-keys)

Example:

```
$array = [
    'First Name' => 'John',
    'Last Name' => 'Doe',
    'email' => 'john.doe@example.com',
    'Field Experience' => 10,
    'Current Job' => 'Software Engineer',
    'Department' => 'Web Development'
];

keys.csv
|------------------|------------|
| First Name       | first_name |
|------------------|------------|
| Last Name        | last_name  |
|------------------|------------|
| Field Experience | experience |
|------------------|------------|
| Current Job      | job        |
|------------------|------------|
| Department       | department |
|------------------|------------|

$sourceCsv = new \ArrayKey\Map\Source\SourceCsv(new \ArrayKey\Map\FileValidator(__DIR__ . '/keys.csv'));
$source = new \ArrayKey\Map\Source($sourceCsv, $array);

print_r($source->getSourceArray());
//result:
Array
(
    [First Name] => John
    [Last Name] => Doe
    [email] => john.doe@example.com
    [Field Experience] => 10
    [Current Job] => Software Engineer
    [Department] => Web Development
)

print_r($source->getMappedArray());
//result:
Array
(
    [first_name] => John
    [last_name] => Doe
    [email] => john.doe@example.com
    [experience] => 10
    [job] => Software Engineer
    [department] => Web Development
)

```

3. Xml Mapping to map array keys
--------------------------------

[](#3-xml-mapping-to-map-array-keys)

Example:

```
$array = [
    'First Name' => 'John',
    'Last Name' => 'Doe',
    'email' => 'john.doe@example.com',
    'Field Experience' => 10,
    'Current Job' => 'Software Engineer',
    'Department' => 'Web Development'
];

keys.xml

            First Name
            first_name

            Last Name
            last_name

            Field Experience
            experience

            Current Job
            job

            Department
            department

$sourceXml = new \ArrayKey\Map\Source\SourceXml(new \ArrayKey\Map\FileValidator(__DIR__ . '/keys.xml'));
$source = new \ArrayKey\Map\Source($sourceXml, $array);

print_r($source->getSourceArray());
//result:
Array
(
    [First Name] => John
    [Last Name] => Doe
    [email] => john.doe@example.com
    [Field Experience] => 10
    [Current Job] => Software Engineer
    [Department] => Web Development
)

print_r($source->getMappedArray());
//result:
Array
(
    [first_name] => John
    [last_name] => Doe
    [email] => john.doe@example.com
    [experience] => 10
    [job] => Software Engineer
    [department] => Web Development
)

```

Limitation
==========

[](#limitation)

The library is made to work on single arrays only, not multidimensional arrays.

LICENSE
=======

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2892d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c696bf597ea0fdd1fd166ce20d7c15c873f16547e874bd67ecb70c4abfdb2cb?d=identicon)[alaa-almaliki](/maintainers/alaa-almaliki)

---

Top Contributors

[![alaa-almaliki](https://avatars.githubusercontent.com/u/7830984?v=4)](https://github.com/alaa-almaliki "alaa-almaliki (1 commits)")

---

Tags

array-helperarray-manipulationsphp-arrayphp-libraryphp arrays array-key-map

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alaa-array-key-map/health.svg)

```
[![Health](https://phpackages.com/badges/alaa-array-key-map/health.svg)](https://phpackages.com/packages/alaa-array-key-map)
```

###  Alternatives

[inovector/mixpostapp

Standalone application with the Laravel Package of Mixpost Lite pre-installed and configured

1232.9k](/packages/inovector-mixpostapp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
