A simple recursive method is required for full combination? Php combination 1 $ a [] array (book1, book2); combination 2 $ a [] array (1, 2, 3); combination 3 $ a [] array (z, y, x); 4 $ a [] array (sd, sds, sdsd); $ outputcombination ($ a, 0); echopre; print_r ($ output );
A simple recursive method is required for full combination? Php // combination 1 $ a [] = array ('book1', 'book2'); // combination 2 $ a [] = array ('1', '2 ', '3'); // combination of 3 $ a [] = array ('Z', 'y', 'x '); // combination 4 $ a [] = array ('sd', 'sds ', 'sdsd'); $ output = combination ($ a, 0); echo "pre "; print_r ($ output );//
A simple recursive method for full combination
<无>
"; Print_r ($ output); // other combinations can be directly converted into an array as needed. // note that the key value must be a digital function combination (& $ input_arr, $ index) {if ($ index> = sizeof ($ input_arr)-1) {return $ input_arr [$ index];} else {$ low_ B = combination ($ input_arr, $ index + 1); $ B = array (); foreach ($ input_arr [$ index] as $ ch) foreach ($ low_ B as $ low_arr) $ B [] = array_merge (array ($ ch), is_array ($ low_arr )? $ Low_arr: array ($ low_arr); return $ B ;}}