PHP code example of medz / create-order-length-php
1. Go to this page and download the library: Download medz/create-order-length-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
medz / create-order-length-php example snippets
use Medz\Component\CreateOrderLength;
// 用于存储实例中生成的数据
$arr = array();
// 构造方法中支持快速设置需要的各个参数。
// $cls = new CreateOrderLength([int $length = 1 | array [int $lrngth = 1, bool $isStaticLength = false]], array $keys = [...]);
$cls = new CreateOrderLength();
// 设置生成的最大长度
// $cls->setLength(int $length, [bool $isStaticLength = false])
$cls->setLength(3);
// 设置回调方法,传入匿名函数
$cls->setCallable(function ($str) use (&$arr) {
array_push($arr, $str);
});
// 设置用于生成字符串的字符组合
// 默认值是a-z0-9
// $cls->setKeys(array(...))
// 开始生成
// 支持设置前置字符串,前置字符串将会被计算到长度当中。
// $cls->start([$pre])
$cls->start();