Skip to content

lunkkun/php-permutations-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Permutations Generator

Summary

A PHP Generator that generates all possible permutations for a given array of values.

Important note

I've optimized the code for performance. Therefore, the order in which the permutations are generated, might differ from what you might expect. To get the permutations in ascending order, you can reverse() every result you get from the generator.

Installation

With composer:

composer require lunkkun/permutations-generator

Usage

<?php

$array = range(0, 2);
$generator = new \Lunkkun\PermutationsGenerator\PermutationsGenerator($array);

foreach ($generator as $permutation) {
    print_r($permutation);
}

License

PHP Permutations Generator is open-sourced software licensed under the MIT license.

About

A PHP generator that generates all possible permutations for a given array of values.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages