php 0000至9999

发布时间:2022-04-26 14:33:58    发布者:文昌文城莱奥网络技术工作室    浏览次数:864

$tmp=array();
        $num=0;
        for($i=0;$i<10;$i++){
            for($j=0;$j<10;$j++){
                for($k=0;$k<10;$k++){
                    for($l=0;$l<10;$l++){
                        $x=(int)($i.$j.$k.$l);
                        if(!in_array($x,$tmp)){
                            //echo $x,'<br/>';
                            if (mb_strlen($x) == 3) {
                                $x = "0" . $x;
                            }else if(mb_strlen($x) == 2){
                                $x = "00" . $x;
                            }else if(mb_strlen($x) == 1){
                                $x = "000" . $x;
                            }
                            $tmp[$x]=(string)$x;
                            $num++;
                        }
                    }
                }
            }
        }
        dump($tmp);
        echo '<hr/>共有:',$num,'个';
        die;