All pastes #561490 Raw Edit

Miscellany

public php v1 · immutable
·published 2007-06-12 14:06 UTC
rendered paste body
<?php$startCode = 32;$endCode = 126;function gen(&$resultArray, $min, $max, $parentStr) {   global $startCode, $endCode;   if (strlen($parentStr) + 1 >= $min && !isset($resultArray[strlen($parentStr)+1])) {     $resultArray[strlen($parentStr)+1] = array();   }   for ($i = $startCode; $i <= $endCode; $i++) {     $str = $parentStr.chr($i);     if (strlen($str) >= $min) {         array_push(&$resultArray[strlen($str)],$str);     }     if (strlen($str) < $max) {       gen(&$resultArray,$min,$max,$str);     }   }}function generate($min,$max) {    $resultArray = array();    gen(&$resultArray, $min, $max, "");    return $resultArray;}$arr = generate(3, 5);echo "<pre>";print_r($arr);echo "</pre>";?>