2017 © Pedro Peláez
 

library arraykeycombiner

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

image

jelle-s/arraykeycombiner

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

  • Wednesday, January 11, 2017
  • by Jelle-S
  • Repository
  • 1 Watchers
  • 0 Stars
  • 95 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

ArrayKeyCombiner

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter., (*1)

use Jelle_S\Util\Combiner\ArrayKeyCombiner;

// Search this array of arrays for intersections and extract them, using a
// delimiter to combine the keys. Limit the number of iterations to search for
// intersections to 10.000, limit the minimum size of intersections to 3, set
// the key delimiter to a comma.
$arrays = array(
 array(
   'a' => 1,
   'b' => 2,
   'c' => 3,
   'd' => 4,
   'e' => 9,
 ),
 array(
   'a' => 1,
   'b' => 2,
   'c' => 3,
   'e' => 9,
 ),
 array(
   'a' => 1,
   'b' => 42,
   'c' => 3,
   'd' => 4,

 ),
 array(
   'b' => 42,
   'c' => 3,
   'a' => 1,
 ),
 array(
   'z' => 26,
   'e' => 9,
   'a' => 1,
 ),
);
$combiner = new Jelle_S\Util\Combiner\ArrayKeyCombiner($arrays, 3, 10000, ',');
print_r($combiner->combine());

Output:, (*2)

Array
(
    [4] => Array
        (
            [a] => 1
            [e] => 9
            [z] => 26
        )

    [0,1] => Array
        (
            [a] => 1
            [b] => 2
            [c] => 3
            [e] => 9
        )

    [2,3] => Array
        (
            [a] => 1
            [c] => 3
            [b] => 42
        )

    [2,0] => Array
        (
            [d] => 4
        )

)

The 'a' and 'z' keys of the array with key '4' were not combined because the threshold for combinations is 3, and combining them would result in a combined array with only two elements., (*3)

The arrays with keys '2' and '0' were combined because after extracting the combinations, these two arrays were identical, and the threshold has no effect for identical arrays, they are always combined., (*4)

The Versions

11/01 2017

dev-develop

dev-develop

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Jelle Sebreghts

26/12 2016

dev-master

9999999-dev

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

  Sources   Download

GPL-3.0+

The Requires

 

by Jelle Sebreghts

26/12 2016

1.0.2

1.0.2.0

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

  Sources   Download

GPL-3.0+

The Requires

 

by Jelle Sebreghts

13/12 2016

1.0.1

1.0.1.0

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

  Sources   Download

GPL-3.0+

The Requires

 

by Jelle Sebreghts

13/12 2016

1.0.0

1.0.0.0

Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.

  Sources   Download

GPL-3.0+

The Requires

 

by Jelle Sebreghts