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

  • SEARCH
  • Home
  • 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 7834821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:20:27+00:00 2026-06-02T13:20:27+00:00

If you found the title misleading, sorry. I couldn’t really come up with a

  • 0

If you found the title misleading, sorry. I couldn’t really come up with a good title for this question.

I have two arrays, that I’m merging together in a function:

$arr1['something']['secondary_something'][]="foo1";
$arr1['something']['secondary_something'][]="foo2";
$arr1['something']['secondary_something'][]="foo3";

$arr2['something']['secondary_something'][]="foo4";
$arr2['something']['secondary_something'][]="foo5";

function something($array_, $array_new) {

$array=array_merge_recursive($array_,$array_new); // to combine/merge both arrays

print_r($array);//debugg

}

Now that function simply prints this (which is all good):

Array ( [something] => Array ( [secondary_something] => Array ( [0] => foo1 [1] => foo2 [2] => foo3 [3] => foo4 [4] => foo5 ) ) )

But I need to work with the new data, that has been merged to the primary array. So I need to work $arr2, but only once it has been merged with $arr1.

When I say I need to “work with the new data”, var_export() is one of the things I need to do with the array.

If I simply do a echo var_export($array_new,true);, I get this:

array ( 'something' => array ( 'secondary_something' => array ( 0 => 'foo4', 1 => 'foo5', ), ), )

When I need this:

array ( 'something' => array ( 'secondary_something' => array ( 3 => 'foo4', 4 => 'foo5', ), ), )

^^ Notice how the array keys are 3 and 4, not 1 and 2. Because it has been merged with the primary array ($arr1).

Hope you guys understand what I’m trying to do.

Any ideas?

Thanks xD

  • 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-02T13:20:28+00:00Added an answer on June 2, 2026 at 1:20 pm
    echo var_export(array_intersect($array['something']['secondary_something'], $arr2['something']['secondary_something']), true);
    

    EDIT This works, but you lose the multidimensional aspect of the array. You’ll need to write a recursive function to step through the entire array if you want to preserve the something and secondary_something aspect in your var_export

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title is my question. I already found a topic related to this here
Found this question that explained a way to communicate between layers. However there is
I found many solutions to this question for GNUPlot 4.2+ using title column, columheader
I have a call to a 404 page in a controller: $this->set('title','Page Not Found');
The title asks it all. I have found an example that looked something like
I can't find it documented anywhere :/ (question is the title) found this but
I have found several topics with this title, but none of their solutions worked
Well the title pretty much sums the question. The only thing I found is
The title is a bit awkward but I couldn't found a better one. My
Today I found this query in our code that pulls up a list of

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.