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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:56:28+00:00 2026-05-28T17:56:28+00:00

I need to combine 2 arrays under the same key by appending Array2 to

  • 0

I need to combine 2 arrays under the same key by appending Array2 to Array1:

Array1
(
    [0] => value1
    [1] => value2
    [2] => value3
    [3] => value4
    [4] => value5
    [5] => value6
    [6] => value7
)
Array2
(
    [0] => add1
    [1] => add2
    [2] => add3
    [3] => add4
    [4] => add5
    [5] => add6
    [6] => add7
)

so that Array3 looks like this:

Array1
(
    [0] => value1add1
    [1] => value2add2
    [2] => value3add3
    [3] => value4add4
    [4] => value5add5
    [5] => value6add6
    [6] => value7add7
)

I searched through php.net but I wasn’t able to find anything. Any help would be much appreciated! Thank you in advance for your input.

  • 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-28T17:56:29+00:00Added an answer on May 28, 2026 at 5:56 pm

    array_mapdocs makes looping superfluous in this case:

    $arr1 = array('value1','value2','value3');
    $arr2 = array('add1','add2','add3');
    $merged = array_map(function($x, $y) { return $x . $y; }, $arr1, $arr2);
    

    If you don’t have PHP5.3+ (or you don’t like lambda) you’ll need to define the closure in a separate function and reference that function’s name instead inside your array_map call.

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

Sidebar

Related Questions

I have 3 byte arrays in C# that I need to combine into one.
I have two arrays I want to combine. I need to take the values
I have an array of arrays, like so: [['1','2'],['a','b'],['x','y']] I need to combine those
I need to sort 20+ arrays, already on the GPU, each of the same
I have three single-dimensional arrays and I need to combine them into one 3-dimensional
I need to combine to a string column and the result of a row_number()
I have a MySql database with three tables I need to combine in a
I need to create and combine several expressions for child entity into one to
I need to convert the function path::combine(path1, path2). Please help me if you have
I need to extract data from a .mpp file on the network and combine

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.