[PHP] 纯文本查看 复制代码
function jiami($str,$jj=0){
$arr1 = array("3","4","5","6","7","8","9","0");
$arr2= array("221","2221","22221","222221","2222221","22222221","222222221","2222222221");
for($i=7;$i>=0;$i--){
$str = str_replace($arr1[$i],$arr2[$i],$str);
}
//if(strpos($str,"3") ===false && strpos($str,"4") ===false && strpos($str,"5") ===false && strpos($str,"6") ===false && strpos($str,"7") ===false && strpos($str,"8") ===false && strpos($str,"9") ===false && strpos($str,"0") ===false ) return array("jg"=>$str,"cj"=>$jj,"len"=>strlen($str));
if($jj>=10)return array("jg"=>$str,"cj"=>$jj,"len"=>strlen($str));
return jiami2($str,$jj);
}
function jiami2($str,$jj){
$arr1 = array("3","4","5","6","7","8","9","0");
$arr2= array("1221","12221","122221","1222221","12222221","122222221","1222222221","12222222221");
for($i=7;$i>=0;$i--){
$str = str_replace($arr2[$i],$arr1[$i],$str);
}
$jj++;
return jiami($str,$jj);
}
function jiemi($str,$jj=0){
$arr1 = array("3","4","5","6","7","8","9","0");
$arr2= array("221","2221","22221","222221","2222221","22222221","222222221","2222222221");
for($i=7;$i>=0;$i--){
$str = str_replace($arr2[$i],$arr1[$i],$str);
}
$jj--;
if($jj<=0) return $str;
return jiemi2($str,$jj);
}
function jiemi2($str,$jj){
$arr1 = array("3","4","5","6","7","8","9","0");
$arr2= array("1221","12221","122221","1222221","12222221","122222221","1222222221","12222222221");
for($i=7;$i>=0;$i--){
$str = str_replace($arr2[$i],$arr1[$i],$str);
}
return jiemi($str,$jj);
}