Home  >  Article  >  Backend Development  >  字符结合类型的题目

字符结合类型的题目

WBOY
WBOYOriginal
2016-06-13 13:13:31775browse

字符组合类型的题目
题目如下:

有一串字符集,如:0123456789,现在需要任意用其中的字符,组成四位字符串,一共有:10*9*8*7种计算结果,现在怎样输出这些字符呢,谢谢。。

------解决方案--------------------
仅供参考

PHP code

printStr(str_split('012'));
function printStr($arr, $length = 4, $str = '')
{
    if(empty($arr) || !is_array($arr))
    {
        return;
    }
    foreach($arr AS $k=> $v)
    {
        $str    .= $v;
        if(strlen($str)';
        }
        $str    = substr($str, 0, -1);
    }
} <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn