Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

How to combine 2 arrays with similar values in php?

I am getting 2 arrays and i have to modified that according to my need. please help.

first array is having case_ids.

$caseId = array( array('case_id' => 1),
          array('case_id' => 2),
          array('case_id' => 3), 
          array('case_id' => 3), 
          array('case_id' => 5));

second array is having some data with notice_case_ids from child table.

$noticeDetails = array (array('notice_case_id => 1,
                              'notice_name' => abc),
                       array('notice_case_id => 1,
                              'notice_name' => xyz)
                       array('notice_case_id => 2,
                              'notice_name' => pqr)
                      array('notice_case_id => 3,
                              'notice_name' => lmn));

My desired output should be :

$finalData = 'data' => 
                    [0] =>
                         'case_id' => 1,
                         'notice_details' =>
                            [0] =>
                              'notice_case_id => 1,
                              'notice_name' => abc,
                            [1] => 
                              'notice_case_id => 1,
                              'notice_name' => xyz
                  [1] =>
                         'case_id' => 2,
                         'notice_details' =>
                            [0] =>
                              'notice_case_id => 2,
                              'notice_name' => pqr,
                  [2] =>
                         'case_id' => 3,
                         'notice_details' =>
                            [0] =>
                              'notice_case_id => 3,
                              'notice_name' => lmn,
                  [3] =>
                         'case_id' => 4,
                         'notice_details' => (),
                  [4] =>
                         'case_id' => 5,
                         'notice_details' => (),

                        
               

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...