如何通过索引合并两个数组

I have two arrays .. first array like this :

$questions = [
    "type" => "form",
    "controls" => []
];

and second array is filled by foreach loop like this :

$count = 0;
foreach($x as $y){
    $controls [
        "id" => $y.$count,
        "id2" => $y.$count+1,
    ]

    $count++;
}

I want to merge all values from the second array to controls index from first array

any help please

No need to merge, just put the result directly into the location you want them in the loop

$questions = [
        "type" => "form",
        "controls" => []
    ];   

$count = 0;
foreach($x as $y){
    $questions['controls'][] =  ["id" => $y.$count,
                                 "id2" => $y.$count+1];
    $count++;
}

Just do:

$questions['controls'] = $controls;

You also need to fix your syntax for filling in $controls, it should be:

$controls[] = [
    "id" => $y.$count,
    "id2" => $y.$count+1,
];