Download the PHP package macocci7/php-combination without Composer

On this page you can find all versions of the php package macocci7/php-combination. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-combination

PHP-Combination

1. Features

PHP-Combination is a simple PHP library to make combinations from array elements.

PHP-Combination can:

2. Contents

3. Requirements

4. Installation

5. Classes

There're 2 types of classes for the same methods.

5.1. Combination

This class returns the result as type of array.

5.2. CombinationGenerator

This class returns the result as type of Generator object.

5.3. How to choose the class to use

There might be 3 factors.

  1. The number of elements of the param and result of all()

    If the array of the param has $n elements,

    the number of array elements of returned array will be:

    $n formula elements
    1 2 ** 1 - 1 1
    5 2 ** 5 - 1 31
    10 2 ** 10 - 1 1,023
    20 2 ** 20 - 1 1,048,575
    30 2 ** 30 - 1 1,073,741,823
    40 2 ** 40 - 1 1,099,511,627,775
    50 2 ** 50 - 1 1,125,899,906,842,623
    60 2 ** 60 - 1 1,152,921,504,606,846,975
    62 2 ** 62 - 1 4,611,686,018,427,387,903
  2. Memory limit on your environment

    Memory usage depends on:

    • the number of array elements to return
    • the type of data

    Combination uses much more memory than CombinationGenerator.

  3. execution time

    Looping Generator takes much longer time than looping array.

In some cases, CombinationGenerator takes several times longer than Combination.

However, using an array with many elements as an argument can cause Combination to exceed memory limits.

In that case, use CombinationGenerator.

It will never exceeds the memory limit, and certainly complete the task.

6. Methods

6.1. Macocci7\PhpCombination\Combination

6.2. Macocci7\PhpCombination\CombinationGenenrator

7. Limit on the Number of Array Elements

The number of array elements of the param:

This limit is set to ensure that the number of elements in the returned array does not exceed the PHP upper limit on the index number of array.

The max index number of array in PHP equals to PHP_INT_MAX.

PHP_INT_MAX:

8. Usage

8.1. Basic Usage

8.1.1 Combination

8.1.2. CombinationGenerator

8.2. Using Combination

8.3. Using Combination with Sorting

8.4. Using CombinationGenerator

8.5. Using In PHPUnit

For Example, fromArray() method can be quite useful for testing with data providers of PHPUnit.

Here's an example for testing the class for ordering products,

with patterns of size, color and amount.

9. Examples

10. LICENSE

MIT


Document Created: 2023/11/11

Document Updated: 2025/01/04

Copyright 2023 - 2025 macocci7


All versions of php-combination with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package macocci7/php-combination contains the following files

Loading the files please wait ....