php排列组合算法
<?php $arr=[['a','b','c','d'],['2','3','4','5'],[',','.','?',';']]; $num = count($arr); if ($num === 0) return false; if ($num === 1) return $arr[0]; while(count($arr) > 1) { $arr_first = array_shift($arr); $arr_second = array_shift($arr); $c = array(); foreach ($arr_first as $v) { $v = (array) $v; foreach ($arr_second as $val) { $c[] = array_merge($v, (array) $val); } } array_unshift($arr, $c); unset($c); } print_r($arr);exit; return $arr[0]; ?>
结果: