All pastes #784849 Raw Edit

Mine

public text v1 · immutable
·published 2007-11-19 21:40 UTC
rendered paste body
<?php


class perm_uplow{
    var $str="";
    var $len_str=0;
    var $out_ar=array();
    var $out_str=array();

    function perm_uplow($str){
        $this->str=$str;
        $this->len_str=strlen($str);
    }

    function get_perm_uplow(){
        $len=strlen($this->str);
        $this->create_perm($this->str,"");
        $this->creat_array_p($this->out_ar);
    }

    function create_perm($str,$val=""){
        if ($str!=""){
            $this->out_ar[]=array($val.strtolower($str{0}),$this->create_perm(substr($str,1,strlen($str)),$val.strtolower($str{0})) );
            $this->out_ar[]=array($val.strtoupper($str{0}),$this->create_perm(substr($str,1,strlen($str)),$val.strtoupper($str{0})) );
        }
    }

    function creat_array_p($a=array()){
        while (list($key, $value) = each ($a)) {
        if(count($value)<1) continue;
           if((gettype($value)=="array") && (count($value)>0)) $this->creat_array_p($value);
           elseif($this->len_str==strlen($value)) $this->out_str[]=$value;
        }
    }

    function get_out_str(){
        return $this->out_str;
    }
    function get_out_ar(){
        return $this->out_ar;
    }
    function get_len_str(){
        return $this->len_str;
    }

}

//example of use
$t=microtime();
$a = new perm_uplow("asdfz");
$a->get_perm_uplow();
print_r($a->get_out_str());
echo $t-microtime(); 


?>