How to merge two arrays

how to merge two arrays, put the remark corresponding to id in data2 into the id corresponding to data1, and the final result is data3

const data1 = [
    { "id": 1, "url": "1111" },
    { "id": 2, "url": "111" },
    { "id": 3, "url": "22222" },
    { "id": 4, "url": "222" },
    { "id": 5, "url": "2222" },
    { "id": 6, "url": "22222" }
]
const data2 = [
    { "id": 1, "remark": "1" },
    { "id": 2, "remark": "2" },
    { "id": 3, "remark": "" },
    { "id": 4, "remark": "" },
    { "id": 5, "remark": "" },
    { "id": 6, "remark": "beizhu6" }
]
function fun(arr1, arr2) {
    arr1.map(item => {
        arr2.map(item2 => {
            if (item.id == item2.id) {

            }
        });
    });
    arr2 = [];
    return arr1
}
fun(data1,data2);

data3=[
    { "id": 1, "url": "1111", "remark": "1" },
    { "id": 2, "url": "111", "remark": "2" },
    { "id": 3, "url": "22222", "remark": "" },
    { "id": 4, "url": "222", "remark": "" },
    { "id": 5, "url": "2222", "remark": "" },
    { "id": 6, "url": "22222", "remark": "beizhu6" }
]
Mar.12,2021


<?php
$data1 = '[{"id":1,"url":"1111"},{"id":2,"url":"111"},{"id":3,"url":"22222"},{"id":4,"url":"222"},{"id":5,"url":"2222"},{"id":6,"url":"22222"}]';
$data2 = '[{"id":1,"remark":"1"},{"id":2,"remark":"2"},{"id":3,"remark":""},{"id":4,"remark":""},{"id":5,"remark":""},{"id":6,"remark":"beizhu6"}]';
$data1 = json_decode($data1,true);
$data2 = json_decode($data2,true);
echo json_encode(array_merge_recursive($data1, $data2));

system functions are easy to handle

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e50e4a-43bc8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e50e4a-43bc8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?