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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:35:58+00:00 2026-05-23T08:35:58+00:00

I Need This Output.. 1 3 5 2 4 6 I Want to use

  • 0

I Need This Output..

1 3 5
2 4 6

I Want to use Array function like array(1,2,3,4,5,6). If i Edit this array like array(1,2,3) means the output need to show like

1 2 3

The concept is Maximum 3 Column only.If we give array(1,2,3,4,5) Means the output should be

1 3 5 
2 4

Suppose we will give array(1,2,3,4,5,6,7,8,9) Means o/p is

1 4 7
2 5 8
3 6 9

Maximum 3 Column only.Depends upon the the given input the rows will be create with 3 column.Is This is Possible with PHP?Am Doing small Research & Development in Array Functions.I think this possible.Will you help me?
For more info:I/p :array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)
O/P:

1  6   11 
2  7   12 
3  8   13 
4  9   14 
5  10  15
  • 1 1 Answer
  • 1 View
  • 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-23T08:35:59+00:00Added an answer on May 23, 2026 at 8:35 am

    Getting number of rows is as easy as ceiling(total number of elements / elements per row). All you need to do is to copy the elements from one one-dimensional array to an other two-dimensional array. One possible method:

    <?php
    $input = array(
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
    );
    $col = 3;
    $row = ceil(count($input) / $col);
    $output = array();
    while(count($input)){
        $output[] = array_splice($input, 0, $row);
    }
    for($i = 0; $i < $row; $i++) {
        $temp = array();
        for($j = 0; $j < $col; $j++) {
            if (isset($output[$j][$i])) {
                $temp[] = $output[$j][$i];
            }
        }
        echo implode(", ", $temp) . "\n";
    }
    

    Output

    1, 6, 11
    2, 7, 12
    3, 8, 13
    4, 9
    5, 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a multi-dimensional array in php and want to use it
I am getting the output as 0,1,2,3. I need this to be split into
I was following this tutorial . I need to use a php file's ouput
I need this for calling a C function from Java class (JNI) and I
This is continued from thread: Python array multiply I need to multiply array vs
I'm thinking to use Array to store this tiny data instead using Database. But,
I'm trying to use vsprintf() to output a formatted string, but I need to
I want to use yad to show a list of items and then execute
Im buliding a shopping cart and want to use a 2d array to store
Kind of need help understanding what this code actually outputs. Does it out put

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.