我正在寻找可以生成以下内容的 PHP 想法/代码/算法:
我有 5 个字符字符串 [a-zA-Z0-9]
我想用可变过滤器生成排列
筛选 :
- 字符串是“W”
- 字符串是一个数字
- 字符串是“T”
- 字符串是大写的
- 字符串是“3”
编辑:
<?php
$reset = fopen('list.txt', 'w');
fclose($reset);
$chars = str_split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
$file = fopen('list.txt', 'a+');
foreach ($chars as $c0) {
foreach ($chars as $c1) {
foreach ($chars as $c2) {
foreach ($chars as $c3) {
foreach ($chars as $c4) {
$filter = "/[a-z][a-z][a-z][a-z][A-Z]/";
$list = $c0 . $c1 . $c2 . $c3 . $c4;
if (preg_match($filter, $list)) {
$data = $list . "\n";
file_put_contents('list.txt', $data, FILE_APPEND);
}
}
}
}
}
}
fclose($file);
?>