meniam/排列

PHP 上的排列算法

V1.0.3 2017-02-13 16:08 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:00:53 UTC


README

生成定义的元素数量的所有排列

示例

<?php

$permutation = new Permutation(3);

foreach ($i = 0; $i <= $permutation->count(); $i++) {
    var_dump($permutation->current()); // array like [0, 1, 2] or [2, 1, 0]
    $permutation->next();
}

var_dump($permutation->getByPos('Some Unique Hash Or Integer'));