时间:2021-07-01 10:21:17 帮助过:6人阅读
$str = 'abc';$res = Arrangement( $str );print_r($res);function Arrangement($arr = array(), $res = '') { if(! is_array($arr) ) $arr = str_split($arr); if(empty($arr)) $array[] = $res; else foreach($arr AS $k => $v) { unset($arr[$k]); foreach( Arrangement($arr, $res . $v) AS $t) $array[] = $t; $arr[$k] = $v; } return $array;}
Array( [0] => abc [1] => acb [2] => bca [3] => bac [4] => cab [5] => cba)
非常感谢,是我要的效果