All modes to combine two arrays : <p>I have a dynamic array in this structure:</p>

<pre><code>$arr = [
    ['R1', 'R2'],
    ['A1', 'A2', 'A3'],
    ['M1', 'M2']
];
</code></pre>

<p>i want to find all combinations for this array i.e:</p>

<pre><code>R1A1M1
R1A1M2
R1A2M1
R1A2M2
R1A3M1
R1A3M2
R2A1M1
R2A1M2
R2A2M1
R2A2M2
R2A3M1
R2A3M2
</code></pre>

<p>because array length is not static we must use a recursive function to solve this problem.
what is code in PHP or js for this problem?</p>

<p>thank you</p>
