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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:06:33+00:00 2026-06-02T15:06:33+00:00

I have 2 multidimentional arrays: array1[0][0] = ‘yes’; array1[0][1] = ‘no’; array1[1][0] = ‘gilbert’;

  • 0

I have 2 multidimentional arrays:

array1[0][0] = 'yes';
array1[0][1] = 'no';
array1[1][0] = 'gilbert';
array1[1][1] = 'duncan';

and

array2[0][0] = 'good';
array2[0][1] = 'bad';
array2[1][0] = 'vegetables';
array2[1][1] = 'chocolate';

I want to create a new array from this 2 arrays such that:

array3[0][0] = 'yes';
array3[0][1] = 'no';
array3[0][2] = 'good';
array3[0][3] = 'bad';
array3[1][0] = 'gilbert';
array3[1][1] = 'duncan';
array3[1][2] = 'vegetables';
array3[1][3] = 'chocolate';

I am using PHP. How do I achieve this. PHP array_merge() appends one array to another. What I want is to create a new array with the two arrays side by side.

  • 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-02T15:06:35+00:00Added an answer on June 2, 2026 at 3:06 pm

    You’ll need to just walk them. You’ve defined a fairly specific (and interesting) way of merging them. I’d probably recommend a function like this:

    function my_combine_arrays()
    {
        // This lets us accept N arrays as an input.
        $arrList = func_get_args();
        $retval = array();
        foreach ($arrList as $array)
        {
            // Note the $key here.  If the arrays have different key types
            // like an assoc, you may have issues.
            foreach ($array as $key=>$arrsub)
            {
               foreach ($arrsub as $arritem)
               {
                   $retval[$key][] = $arritem;
               }
            }
        }
        return $retval;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multidimentional array composed of latin and Berber strings that I want
This is based on my last question. I have these arrays: var array1 =
I have a multidimensional array of arrays (source below), where my keys and values
I have many large multidimensional NP arrays (2D and 3D) used in an algorithm.
I have a multidimensional array, and I would have multiple arrays within it. Some
hi i have multidimensional array in php i want to remove an index from
I have a multidimensional array, here: $noticeDate = json_encode( $noticesDates ); and I want
I have a large multidimensional array and I basically want to drop the first
I am new to C and C++ and I have only worked with arrays
I have two questions regarding the multidimensional arrays. I declared a 3D array using

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.