PHP code example of amsoell / laravel-collection-normalize-keys

1. Go to this page and download the library: Download amsoell/laravel-collection-normalize-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/ */

    

amsoell / laravel-collection-normalize-keys example snippets


$collection = collect([
  [ 'a' => 1, 'b' => 2],
  [ 'a' => 1, 'c' => 3],
  [ 'b' => 1, 'c' => 3],
]);

$collection->normalizeKeys();

// [
//     [ 'a' => 1, 'b' => 2, 'c' => null ],
//     [ 'a' => 1, 'b' => null, 'c' => 3 ],
//     [ 'a' => null, 'b' => 1, 'c' => 3 ],
// ];