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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:12:19+00:00 2026-05-26T21:12:19+00:00

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

  • 0

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 just using numbers as examples. If it was just numbers i could merge and sort but they will be words. So maybe something like

array one: bob,a,awesome

array two: is,really,dude

should read: bob is a really awesome dude

Not really sure how to do this. Does PHP have something like this built in?

  • 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-26T21:12:20+00:00Added an answer on May 26, 2026 at 9:12 pm

    You could write yourself a function like this:

    function array_merge_alternating($array1, $array2) {
        if(count($array1) != count($array2)) {
            return false; // Arrays must be the same length
        }
    
        $mergedArray = array();
    
        while(count($array1) > 0) {
            $mergedArray[] = array_shift($array1);
            $mergedArray[] = array_shift($array2);
        }
        return $mergedArray;
    }
    

    This function expects two arrays with equal length and merges their values.

    If you don’t need your values in alternating order you can use array_merge. array_merge will append the second array to the first and will not do what you ask.

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

Sidebar

Related Questions

Let's make this very easy. What I want: @array = qw/one two one/; my
I want to build two-dimentional array of strings where length of one dimention is
I have a URL of form http://www.example.com?foo=one&foo=two I want to get an array of
Like I have an array Array('one', 'three', 'two'); , and, say, I want to
I want to compare two arrays, one coming from a shoppingcart and the other
Given an array like {one two, three four five}, how'd you calculate the total
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove
I have converted an array to object data like this: <?php $myobject->data = (object)Array('zero','one','two');
I cannot figure out how to set an array to one of two sets
I have a multi dimensional array in PHP. $f = array('one' => array(*doesntmatter*), two

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.