Download the PHP package bentools/string-combinations without Composer

On this page you can find all versions of the php package bentools/string-combinations. 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 string-combinations

Latest Stable Version License CI Workflow Coverage Quality Score Total Downloads

String combinations

A simple, low-memory footprint function to generate all string combinations from a series of characters.

Installation

PHP 7.4+ is required.

composer require bentools/string-combinations

Usage

I want to get all combinations with the letters a, b, c.

Output:

Array output

It will dump all combinations into an array.

Count combinations

It will return the number of possible combinations.

Specifying min length, max length

Output:

Using an array as first argument, and a separator

Output:

No duplicates

You can avoid generating stings having the same letter more than once with the withoutDuplicates() method:

Array ( [0] => a [1] => b [2] => c [3] => aa [4] => ab [5] => ac [6] => ba [7] => bb [8] => bc [9] => ca [10] => cb [11] => cc [12] => aaa [13] => aab [14] => aac [15] => aba [16] => abb [17] => abc [18] => aca [19] => acb [20] => acc [21] => baa [22] => bab [23] => bac [24] => bba [25] => bbb [26] => bbc [27] => bca [28] => bcb [29] => bcc [30] => caa [31] => cab [32] => cac [33] => cba [34] => cbb [35] => cbc [36] => cca [37] => ccb [38] => ccc )

Array ( [0] => a [1] => b [2] => c [3] => ab [4] => ac [5] => ba [6] => bc [7] => ca [8] => cb [9] => abc [10] => acb [11] => bac [12] => bca [13] => cab [14] => cba )

Performance considerations

Because it uses Generators to generate all possible combinations, you can iterate over thousands of possibilities without losing a single MB.

This has been executed on my Core i7 personnal computer with 8GB RAM:

Output:

Generated 19173960 combinations in 5.579s - Memory usage: 2MB / Peak usage: 2MB

Tests

./vendor/bin/phpunit

See also


All versions of string-combinations with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
bentools/cartesian-product Version ^1.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 bentools/string-combinations contains the following files

Loading the files please wait ....