Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Permute multi-dimensional array

$
0
0
Hi,

Does someone know of a recursive way to permute $data? Currently I am using iteration and that sucks.. I tried without luck, online examples were only about 1-dimensional array's.
 
$data = [
  [1,3,4],
  [11,15,16],
  [22,24,25,28],
  [36,38],
  [44,48,50],
  [1,2,3],
  [9,10,11],
];
So that it permutates to:
 
[] = [1,11,22,36,44,1,9]
[] = [1,11,22,36,44,1,10]
[] = [1,11,22,36,44,1,11]
[] = [1,11,22,36,44,2,9]
[] = [1,11,22,36,44,2,10]
[] = [1,11,22,36,44,2,11]
[] = [1,11,22,36,48,1,9]
[] = [1,11,22,36,48,1,10]
[] = [1,11,22,36,48,1,11]
..

Viewing all articles
Browse latest Browse all 13200

Trending Articles