我有两个数组如下:
$grid_data = Array
(
[0] => Array
(
[newsletter_id] => 1
[newsletter_name] => Eywa Solutions
[newsletter_subject] => Holi Wishes
[newsletter_email_body] => Happy Holi to all the friends
[newsletter_call_to_action_status] => 0
[newsletter_call_to_action_text] =>
[newsletter_call_to_action_link] =>
[newsletter_status] => 2
[newsletter_schedule] => 0
[newsletter_created_date] => Mar 17 2014, 16:21 pm
[newsletter_updated_date] => 0
)
[1] => Array
(
[newsletter_id] => 2
[newsletter_name] => Akshay Nikte
[newsletter_subject] => The Don
[newsletter_email_body] => How are yoy Nikte Saheb?
[newsletter_call_to_action_status] => 0
[newsletter_call_to_action_text] =>
[newsletter_call_to_action_link] =>
[newsletter_status] => 2
[newsletter_schedule] => 0
[newsletter_created_date] => Mar 18 2014, 06:52 am
[newsletter_updated_date] => 0
)
)
第二个数组如下:
$LastSendNewsletterDetail = Array
(
[0] => Array
(
[newsletter_id] => 1
[newsletter_sent_count] => 5
[newsletter_sent_date] => 1395121193
)
[1] => Array
(
[newsletter_id] => 2
[newsletter_sent_count] => 7
[newsletter_sent_date] => 1395121227
)
)
现在我想要实现的是从上面的两个数组中相互比较键值(名为newsletter_id )。如果它们彼此匹配,则将数组 $LastSendNewsletterDetail 中的数据插入到第一个数组$grid_data
中。如果它们不匹配,则将空白值插入第一个数组$grid_data
。
例如,所需的最终 $grid_data 数组应如下所示:
$grid_data = Array
(
[0] => Array
(
[newsletter_id] => 1
[newsletter_name] => Eywa Solutions
[newsletter_subject] => Holi Wishes
[newsletter_email_body] => Happy Holi to all the friends
[newsletter_call_to_action_status] => 0
[newsletter_call_to_action_text] =>
[newsletter_call_to_action_link] =>
[newsletter_status] => 2
[newsletter_schedule] => 0
[newsletter_created_date] => Mar 17 2014, 16:21 pm
[newsletter_updated_date] => 0
[newsletter_sent_count] => 5
[newsletter_sent_date] => 1395121193
)
[1] => Array
(
[newsletter_id] => 2
[newsletter_name] => Akshay Nikte
[newsletter_subject] => The Don
[newsletter_email_body] => How are yoy Nikte Saheb?
[newsletter_call_to_action_status] => 0
[newsletter_call_to_action_text] =>
[newsletter_call_to_action_link] =>
[newsletter_status] => 2
[newsletter_schedule] => 0
[newsletter_created_date] => Mar 18 2014, 06:52 am
[newsletter_updated_date] => 0
[newsletter_sent_count] => 7
[newsletter_sent_date] => 1395121227
)
)
如何做到这一点?提前致谢。