PHP: How to match two multidimensional array

前端 未结 3 527
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 02:41

I stuck on this and really don\'t know how to solve it. I have two multi-dimensional arrays and need to match every \"entry_id\" from second array with first one. Then need to c

3条回答
  •  野的像风
    2021-01-26 03:18

    This should work

        foreach($array1 as $i)
    {
        foreach($array2 as $key=>$j)
        {
            if($j['entry_id'] == $i['entry_id'])
            {
                if($array2[$key]['status'] != $i['status'])
                {
                    $j['status'] = array(
                        $i['status'],
                        $j['status'] // the new status
                    );
                }
                continue;
            }
        }
    }
    

提交回复
热议问题