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 8140587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:12:42+00:00 2026-06-06T12:12:42+00:00

I have to array and I want to merge this two array with a

  • 0

I have to array and I want to merge this two array with a main key ( ID ) , and I would like to order alphabetically this NEW array ( the lastname field )

Array ( 
[0] =>
 Array ( [id] => 172 
         [user_id] => 1217330 
         [behaviour_action_id] => 97 
         [state] => accepted 
     ) 
[1] =>
 Array ( 
    [id] => 173
    [user_id] => 1217330 
    [behaviour_action_id] => 97 
    [state] => pending 
     ) ) 

And this array

Array ( 
[1217330 ] => 
Array ( [firstname] => Philip 
        [lastname] => Audet
        [birthdate] => 1995-07-17 
        [id] => 1217330 
        ) 
[232323] => 
Array ( [firstname] => Frédéric 
        [lastname] => Bouchard-Dubé
        [birthdate] => 1995-07-17 
        [id] => 232323
        ) 

And I would like to have this

[0] =>
 Array ( [id] => 172 
         [user_id] => 1217330 
         [behaviour_action_id] => 97 
         [state] => accepted
         [firstname] => Philip 
         [lastname] => Audet 
     ) 
[1] =>
 Array ( 
    [id] => 173
    [user_id] => 1217330 
    [behaviour_action_id] => 97 
    [state] => pending 
    [firstname] => Philip 
    [lastname] => Audet 
     ) ) 

I wont want to have the birthdate index for THIS array, I only want to get the firstname and the lastname from the second array. So I want to math the index USER_ID ( first_table) with ID (second table). I also want to order this new table alphabetically with the lastname (in my exemple, I don’t need to sort it alphabetically, but I will need to do this )

Can some one can help me please ? Thx
Thx

  • 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-06-06T12:12:43+00:00Added an answer on June 6, 2026 at 12:12 pm

    this one? (assuming $arr1 and $arr2 the given arrays)

    $arr3 = array();
    foreach($arr1 as $key=>$val) {
       $arr3[$key] = $val;
       $arr3[$key]["firstname"] = $arr2[$val["user_id"]]["firstname"];
       $arr3[$key]["lastname"] = $arr2[$val["user_id"]]["lastname"];
    }
    
    echo "<pre>";
    print_r($arr3);
    echo "</pre>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two array like this and want to merge like Take 1st index
So basically I have these two arrays I want to merge... array(1) { [first]=>
We have two PHP5 objects and would like to merge the content of one
I have two arrays, I want to merge these two arrays into single array.
i have an array and i want to convert this array in comma seprated
I have a plist with two string arrays. I want to merge these two
array one: 1,3,5,7 array two: 2,4,6,8 the array i want would be 1,2,3,4,5,6,7,8 I'm
I have two arrays array1 and array2. I want to merge these two arrays
I have 2 arrays like below and want to merge them together and not
I have two php arrays like these: Array ( [0] => Array ( [id]

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.