List

Try: ca/tecreations/ViewFile.php -- Online


<?php

$low1 = 'a';
$low2 = 'z';
$mid1 = 'A';
$mid2 = 'Z';
$hi_1 = '0';
$hi_2 = '9';
    
$src = "a";
$lenIndex = 0;

// okay, ready to run...


// do it
for($i = 0; $i < strlen($src); $i++) {
    $sentinel = computeSentinel($src);
    for($j = 0;$j < $sentinel;$j++) {
        if (isAllLow1($src)) {
            $lenIndex = 0;
        }
        if ($lenIndex % pow(10,strlen($src)) == 0) {
            print("Len: " . strlen($src) . " LenIndex: $lenIndex Current: $src<br />\n");
        }
        $src = timcrement($src);
        $lenIndex++;
    }
}



// try to store bulletproof code at the bottom, but alphabetized?

function computeSentinel($str) {
    $sentinel = 0;
    for($i = 0; $i < strlen($str);$i++) {
        $sentinel += pow(62,$i + 1);
    }
    return $sentinel;
}  


function isAllLow1($str) {
    global $low1;
    for($i = 0; $i < strlen($str); $i++) {
        //print("$" . "str[$i]: " . $str[$i] . " Low1: $low1<br />");
        if ($str[$i] == $low1) {} else return false;
    }
    return true;
}

function isAllNines($str) {
    for($i = 0; $i < strlen($str); $i++) {
        if ($str[$i] != '9') return false;
    }
    return true;
}

function timcrement($s) {
    global $lenIndex;
    $newS = timcrement_Recurse(strlen($s),str_split($s));
    return $newS;
}
    
function timcrement_Recurse($i,$src) {
    global $low1, $low2, $mid1, $mid2, $hi_1, $hi_2, $advanced;
    $newS = "";
    if ($i > 0) $i = $i - 1;
    $done = false;
    if ($src[$i] == $low2) { // okay, so at array[i] == [{("'z'")}]
        $src[$i] = $mid1;
    } else if ($src[$i] == $mid2) {
        $src[$i] = $hi_1;
    } else if ($src[$i] == $hi_2) {
        $src[$i] = $low1;
        if ($i == 0) {
            $newS .= $low1;
        } else {
            $newS = timcrement_Recurse($i,$src);
            $done = true;
        }
    } else {
        $temp = ord($src[$i]);
        $temp++;
        $src[$i] = chr($temp);
    }
    if (!$done) for($j = 0; $j < count($src);$j++) $newS .= $src[$j];
    return $newS;
}