PHP Classes
elePHPant
Icontem

PHP Array Intersections: Find intersections between combinations of arrays

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-01-12 (2 years ago) RSS 2.0 feedNot enough user ratingsTotal: 108 All time: 9,083 This week: 556Up
Version License PHP version Categories
arrayintersections 1.0GNU General Publi...5Algorithms, PHP 5, Utilities and Tools
Description Author

This class can find intersections between combinations of arrays.

It takes a list of arrays and find intersections of common element values.

The class can return all the array intersections, as well the largest array intersection.

  Performance   Level  
Name: Jelle Sebreghts <contact>
Classes: 7 packages by
Country: Belgium Belgium
Age: 29
All time rank: 14929 in Belgium Belgium
Week rank: 742 Up5 in Belgium Belgium Up
Innovation award
Innovation award
Nominee: 4x

Details

ArrayIntersections

Build Status Code Climate Test Coverage Issue Count

Tries to find intersections between a combination of arrays.

use Jelle_S\Util\Intersections\ArrayIntersections;

// Get all possible intersections, where the minimum array size of an
// intersection is 3.
$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,
 ),
);
$intersections = new Jelle_S\Util\Intersections\ArrayIntersections($arrays, 3);
print_r($intersections->getAll());

print_r($intersections->getLargest());

Output:

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

    [1] => Array
        (
            [a] => 1
            [c] => 3
            [d] => 4
        )

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

)
Array
(
    [a] => 1
    [b] => 2
    [c] => 3
    [e] => 9
)
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file .codeclimate.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file ArrayIntersections.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file ArrayKeyIntersectionsTest.php Class Class source

Downloadarrayintersections-2017-01-12.zip 16KB
Downloadarrayintersections-2017-01-12.tar.gz 15KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
PHP BitMask Generator Download .zip .tar.gz Composer dependency. Required
 Version Control Reuses Unique User Downloads Download Rankings  
 100%1
Total:108
This week:0
All time:9,083
This week:556Up