Array assembly problem

I have two arrays of indefinite length arr1 and arr2 . Want to assemble a new array res

clipboard.png

Dec.29,2021

not very good at php. It should be universal in js.

var arr1 = [1,2,3];
            var arr2 = ['a','b','c','d'];
            var arr = [];
            arr1.forEach(i=>{
                arr2.forEach(j=>{
                    arr.push([i,j]);
                })
            })
            console.log(arr)

for

$a = [1,2,3];
$b = ['a','b','c','d'];

$res = [];
for($i = 0; $i < count($a); $iPP)
{
    for($j = 0; $j < count($b); $jPP)
    {
        $res[] = [$a[$i],$b[$j]];
    }
}
var_dump($res);
Menu