2017 © Pedro Peláez
 

library priority-array-merge

Merge array with different key priority

image

gianarb/priority-array-merge

Merge array with different key priority

  • Monday, January 12, 2015
  • by GianArb
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Priority merge array

Build Status This lib help you to merge two array with key priority, (*1)

<?php
$mergeManager = new PriorityArray();
$first = [
    'companyId' => 0,
    'companyCode' => 1,
    'companyName' => 1,
];
$second = [
    'companyId' => 1,
    'companyCode' => 0,
    'companyName' => 0,
];
$mergeManager->setMapPriority($first, $second);
$arr1 = [
    'companyId' => '012',
    'companyCode' => 'B353sf',
    'companyName' => 'Fox',
];
$arr2 = [
    'companyId' => '024',
    'companyCode' => 'A352gh',
    'companyName' => 'BBC',
];
var_dump($mergeManager->merge($arr1, $arr2));
// output ["companyId"=>"024", "companyCode": "B353sf", "companyName": "Fox"]

Benchamarks

GianArb\Benchmarks\Util\ArrayMergeEvent
    Method Name                       Iterations    Average Time      Ops/second
    -------------------------------  ------------  --------------    -------------
    mergeTwoArrayWithNativeFunction: [1,000     ] [0.0000039789677] [251,321.46923]
    mergeTwoArrayWithPriority      : [1,000     ] [0.0000096676350] [103,437.91462]

The Versions

12/01 2015

dev-master

9999999-dev

Merge array with different key priority

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

11/01 2015

0.0.1

0.0.1.0

Merge array with different key priority

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

11/01 2015

dev-develop

dev-develop

Merge array with different key priority

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires