PHP code example of aviator / array-map-keys

1. Go to this page and download the library: Download aviator/array-map-keys library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aviator / array-map-keys example snippets


$input = [
    [
        'company' => 'Aviator Creative',
        'owner' => 'Daniel Deboer',
        'email' => '[email protected]',
    ],
    [
        'company' => 'Widget Makers',
        'owner' => 'Jane Doe',
        'email' => '[email protected]',
    ],
];

$callback = function ($key, $value) {
    return [
        $value['owner'] => $value['email'];
    ];
};

$results = array_map_keys($input, $callback);

echo $results;

/*
[
    'Daniel Deboer' => '[email protected]',
    'Jane Doe' => '[email protected]',
]
*/