<?php $AA = array('a','b','c');$BB = array(); function gen($A, $B, $idx) { if ($idx < 0) { if(sizeof($B)>0) print_r($B); return; } gen($A, $B, $idx - 1); array_unshift($B, $A[$idx]); gen($A, $B, $idx - 1); return; } gen($AA, $BB, sizeof($AA)-1);
Standard input is empty
Array ( [0] => a ) Array ( [0] => b ) Array ( [0] => a [1] => b ) Array ( [0] => c ) Array ( [0] => a [1] => c ) Array ( [0] => b [1] => c ) Array ( [0] => a [1] => b [2] => c )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!