Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:45:41+00:00 2026-05-27T06:45:41+00:00

I have two arrays: 1. first array: array 0 => array ‘id’ => int

  • 0

I have two arrays:
1. first array:

array
  0 => 
    array
      'id' => int 1
      'section_id' => int 2
      'class_id' => int 25
      'student_id' => int 1
      'unixdate' => int 1322553600
      'date' => string '2011-11-29' (length=10)
      'attendance' => string 'present' (length=7)
  1 => 
    array
      'id' => int 2
      'section_id' => int 2
      'class_id' => int 25
      'student_id' => int 2
      'unixdate' => int 1322553600
      'date' => string '2011-11-29' (length=10)
      'attendance' => string 'absent' (length=6)

2. second array:

array
  0 => 
    array
      'section_id' => int 2
      'class_id' => int 25
      'student_id' => int 1
      'unixdate' => int 1322553600
      'date' => string '2011-11-29' (length=10)
      'attendance' => string 'absent' (length=7)
  1 => 
    array
      'section_id' => int 2
      'class_id' => int 25
      'student_id' => int 3
      'unixdate' => int 1322553600
      'date' => string '2011-11-29' (length=10)
      'attendance' => string 'absent' (length=6)

ON these array if values of two keys ‘student_id’ and ‘unixdate’ matches I want new array with the id from array one and other from array 2.

OR
replace the ‘attendance’ value to first array if ‘student_id’ and ‘unixdate’ of both array are same.

EDIT
my result should be like this:

array
      0 => 
        array
          'id'  => int 1
          'section_id' => int 2
          'class_id' => int 25
          'student_id' => int 1
          'unixdate' => int 1322553600
          'date' => string '2011-11-29' (length=10)
          'attendance' => string 'absent' (length=7)

How can i do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:45:42+00:00Added an answer on May 27, 2026 at 6:45 am

    did you try with 2 foreach?

    $result = array();
    foreach($array1 as $data1)
    {
      foreach($array2 as $data2)
      {
        if($data1['student_id'] == $data2['student_id'] and
           $data1['unixdate'] == $data2['unixdate'])
        {
            $tmp = array("id" => $data1['id']);
            $tmp = array_merge($tmp, $data2);
    
            $result[] = $tmp;
            break;
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays in PHP. The first array ($author_array) is comprised of user_ids
I have two arrays: 1) The first array: array( [0] => array( [code] =>
I have two arrays. Example of the first array: $arrayOne = array ( 'fruit'
I have two arrays, each containing strings. The first array is a list of
So basically I have these two arrays I want to merge... array(1) { [first]=>
I have two arrays First array has large number of words, i have 2nd
I have two arrays named rows and contacts . The first array rows is
I have two arrays. The first array contains some values while the second array
A PHP question about arrays. Suppose we have two arrays: [first] => Array (
I have two arrays. In first array I have Type and Zone field names.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.