I have 2 nested arrays like this
array:1 [
0 => array:1 [
\"id\" => 6
],
1 => array:1 [
\"id\" => 4
]
]
array:1 [
0 => array:1
To make it simple, I tried with looping:
$arr1 = array(
array("id"=>6),
array("id"=>"4")
);
$arr2 = array(
array("id"=>509),
array("id"=>256)
);
$result = array();
foreach($arr1 as $k=>$a) {
$result[$k] = array("ssh_id"=>$a['id'], "d_id" => $arr2[$k]['id']);
}
You can do this by using for
loop also.
$final = array();
for($i = 0; $i < count($arr1); $i++){
$final[] = array("ssh_id" => $arr1[$i]['id'], "d_id" => $arr2[$i]['id']);
}
Result
Array
(
[0] => Array
(
[ssh_id] => 6
[d_id] => 509
)
[1] => Array
(
[ssh_id] => 4
[d_id] => 256
)
)