Просмотр поста

.
ДоХтор
# aNNiPAk (22.09.2015 / 22:20)
Koenig, А в один столбик, и только пароли, без номера по счету-можно?
Можно
без номеров (+/-)
<?php
$original = 'ptayyjp/p2k7';
#$original = 'qw3er4t';

$array = str_split($original, 2);

if ((sizeof($array) % 2) != 0) {
    $array[] = '';
}

function pr_start($str) {
    if ($str == '') {
        return $str; 
    } else {
        $res = array();
        $res[] = strtolower($str);    
        $res[] = strtoupper($str);
    
        if (strlen($str) > 1) {
            $pice = array();
            $pice[] = $str[0];
            $pice[] = $str[1];
            $res[] = strtoupper($pice[0]) . strtolower($pice[1]);
            $res[] = strtolower($pice[0]) . strtoupper($pice[1]);
        }
    
        return array_unique($res);
    }
}


function pr_merge($a, $b) {
    if (strlen($a[0]) < 3) {
        $a = pr_start($a);
        $b = pr_start($b);
    }
    if ($b == '') {
        return $a;
    }
    $res = array();
    foreach ($a as $c) {
        foreach ($b as $d) {
            $res[] = $c . $d;    
        }
    }
    
    return array_unique($res);
}

function run($array) {
    $cnt = sizeof($array);
    $res = array();
    $rs = array();
    $i = 0;
    $a = 0;
    $b = 1;
    while ($i < $cnt / 2) {
        $res[] = array_unique(pr_merge($array[$a], $array[$b]));

        $i++; $a+=2; $b+=2;
    }
    


    if (sizeof($res) >= 2) {
        run($res);
    } else {
                $return = '';
                foreach ($res[0] as $val) {
                    $return .= $val .'<br />';
                }

    }
echo $return;
        
    
    
}

$rs = run($array);

echo $rs;