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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:54:45+00:00 2026-05-14T05:54:45+00:00

Array starts like this: Array ( [SMART Board] => Array ( [0] => sb1

  • 0

Array starts like this:

Array ( 
  [SMART Board] => Array ( [0] => sb1 [1] => sb2 [2] => sb3 ) 
  [Projector] => Array ( [0] => pr1 [1] => pr2 [2] => pr3 ) 
  [Speakers] => Array ( [0] => sp1 [1] => sp2 [2] => sp3 ) 
  [Splitter] => Array ( [0] => spl1 [1] => spl2 [2] => spl3 ) 
  [Wireless Slate] => Array ( [0] => ws1 [1] => ws2 [2] => ws3 ) 
)

The keys are used as my table columns titles. Their individual arrays are to carry the column information.

I have split it up even further with array_slice and array_merge_recursive to look pretty as 2 arrays – 1 holds the column names, the other looks like this:

Array ( 
  [0] => sb1  
  [1] => sb2  
  [2] => sb3  
  [3] => pr1  
  [4] => pr2  
  [5] => pr3  
  [6] => sp1  
  [7] => sp2  
  [8] => sp3  
  [9] => spl1  
  [10] => spl2  
  [11] => spl3  
  [12] => ws1  
  [13] => ws2  
  [14] => ws3  
)

However, when trying to write the table I’m getting keys 0, 1, 2 as the column data, then row break then 3, 4, 5 then row break… etc.

I need it to be 0, 3, 6, 9, 12 row break 1, 4, 7, 10, 13 row break etc…

How can I either rearrange my array to allow for this, or rewrite how the data goes into the table so that the correct information lines up with the appropriate column?

foreach(unserialize($dl->data) as $data){

    //first 3 are specialinstructions, system, and room
    $uniques = array_slice($data,0,3);

    $rows = array_slice($data,3);
    $rows2 = array_merge_recursive($rows2, $rows);

    //get the specialinstructions, system, and room
    foreach($uniques as $unique){
        echo $unique."<br/>";
    }///foreach uniques

    echo "<br>";

}///foreach unserialized

$numberofrooms = count($rows2[key($rows2)]);
$numberofproducts = count($rows2);
print_r($rows2);

unset($rows);

//write the individual rows
foreach($rows2 as $header=>$rowset){

    $headers[] = $header;

    foreach($rowset as $row){

        $rows[] = $row;

    }//foreach rowset

}//foreach rows2

echo "<p>";
print_r($rows);

echo '<table class="data-table">
          <caption>DL</caption>

          <thead><tr>';
foreach($headers as $header){
    echo "<th>".$header."</th>";
}
echo '</tr></thead>';
echo '<tbody>';
$i = 0;
foreach($rows as $row){
    if($i == 3 || $i == 0){
        echo "<tr>";
        $i = 1;
    }
    echo '<td>'.$row.'</td>';
    if($i == 2){
        echo "</tr>";
    }
    $i++;
}
echo '</tbody></table>';
  • 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-14T05:54:45+00:00Added an answer on May 14, 2026 at 5:54 am

    You could use the original array and the following code to display the way you want:

    $i=0;
    while($i<3){ // 3 is the number of items in each array
        foreach($originalArray as $arr){
            print($arr[$i].'<br/>');
        }
        print('<hr/>');
        $i++;
    }
    

    Not tested but you should get the drift.

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

Sidebar

Ask A Question

Stats

  • Questions 437k
  • Answers 437k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In the case of reading and writing a primitive like… May 15, 2026 at 4:08 pm
  • Editorial Team
    Editorial Team added an answer Try to replace your static text to this one: "HTTP/1.0… May 15, 2026 at 4:08 pm
  • Editorial Team
    Editorial Team added an answer You'll need to upgrade from the jQuery.load function to jQuery.ajax.… May 15, 2026 at 4:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.