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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:22:09+00:00 2026-05-29T19:22:09+00:00

i have an array with recurring values like {1 2 3 4 5 6

  • 0

i have an array with recurring values like

{1
2
3
4
5
6
7
8
9
10
11
12}

and another array with data

{itema
itemb
itemc
itemd}

i wan to split the first array and then to combine with second array that my output looks like ..

{
itema=>1,5,9
itemb=>2,6,10
itemc=>3,7,11
itemd=>4,8,12
}

i want to group the elements of array . Basically they are obtained using xpath and 4 values combine together to become information about a single subject. My basic purpose is to modify first array such that i can print values of same domain together…I want to print

  • 1,2,3,4,
  • 5,6,7,8
  • 9, 10,11, 12

  • Question might look strange, but i am struggling to describ it completely…Sorry for that

    • 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-29T19:22:10+00:00Added an answer on May 29, 2026 at 7:22 pm

      Assuming the first array you talk of is a multi dimensional array, as in

      $firstArray = { a={1,2,3},b={1,2,3} };
      

      What you need to do is loop through each array and create a new one in the process.

      $masterArray = {itema,itemb,itemc,itemd};
      
      
      $newArray = new Array();
      for ($i = 0; $i<$masterArray.length; $i++) {
         for ($j = 0; $j<$firstArray.length; $j++){
            $newArray[$i] = $masterArray[$i]=>$firstArray[$j][$i];
         }
      }
      
      var_dump($newArray);
      

      I haven’t tested the code myself, so I can’t say it’s perfect, but that’s basically what you want to do.
      Feel free to ask questions.

      Edit: As a result of a discussion, I found out that using the array chunk function did what the OP wanted, but not what the question asked.

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

    Sidebar

    Related Questions

    I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
    An array is defined of assumed elements like I have array like String[] strArray
    Have an array of chars like char members[255]. How can I empty it completely
    I have method for converting array of Booleans to integer. It looks like this
    I am recording acceleration data for the x-axis, so I have two values coming
    I already have data in array as $a = array ( [2011-07-09] => array(['new']
    I have some code where I'm returning an array of objects. Here's a simplified
    I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
    if i have array array[0] = jack; array[1] = jill; array[2] = lisa; array[2]
    Let's say I have array of bytes: byte[] arr = new byte[] { 0,

    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.