Download .zip |
Info | Documentation | View files (8) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-01-12 (4 months ago) | Not enough user ratings | Total: 60 | All time: 8,820 This week: 686 |
Version | License | PHP version | Categories | |||
arraykeycombiner 1.0.0 | GNU General Publi... | 5 | Algorithms, PHP 5, Data types |
Description | Author | |
This class can combine arrays finding intersections. Innovation Award
|
Combines arrays by searching for intersections and adding them to the master array. Keys are combined using a delimiter.
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:
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.
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.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (1 file) | ||||
tests (1 file) | ||||
.codeclimate.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
arraykeycombiner-2017-01-12.zip 17KB | |
arraykeycombiner-2017-01-12.tar.gz 15KB | |
Install with Composer |
Needed packages | ||
Class | Download | Why it is needed | Dependency |
---|---|---|---|
PHP Array Intersections | .zip .tar.gz | Composer dependency. | Required |
Version Control | Reuses | Unique User Downloads | Download Rankings | ||||||||||||||||
100% | 1 |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Other classes that need this package |
Class | Why it is needed | Dependency |
---|---|---|
PHP CSS Optimize | Composer dependency. | Required |