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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:50+00:00 2026-05-27T09:18:50+00:00

I have an Array of Arrays and Want to create a Tabular data layout.

  • 0

I have an Array of Arrays and Want to create a Tabular data layout. This is not the exact code, as how their generated is quite the cluster (Coming from COBOL interaction) but this should give me enough to make it work if someone can think of a clean way to code this.

array(
    Array(847.0, 97010, 11)
    Array(847.0, 97012, 10)
    Array(847.1, 97010, 08)
    Array(847.1, 97012, 14)
)

So I want to put these into a Table that looks something like

          97010    97012
    847.0   11      10
    847.1   08      14

The first 2 elements of the arrays will always be the two axis and the 3rd the contents of the table.

Any Suggestions? thanks!

  • 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-27T09:18:51+00:00Added an answer on May 27, 2026 at 9:18 am
    $table = array();
    $columns = array();
    
    // copy the array (x, y, value) into a table
    // keeping track of the unique column names as we go
    foreach ($dataSet as $point) {
        // provided sample data used floats, ensure it is a string
        $x = strval($point[0]);
        $y = strval($point[1]);
        $data = $point[2];
    
        if (!isset($table[$x])) {
          $table[$x] = array();
        }
    
       $table[$x][$y] = $data;
       // quick and dirty style 'unique on insert'
       $columns[$y] = true;
    }
    
    // switch the column names from title => true to just titles
    $columns = array_flip($columns);
    
    // Display the table
    echo '<table>';
    
    // Header row
    echo '<tr>';
    echo '<th>&nbsp;</th>';
    foreach ($columns as $columnTitle) {
        echo '<th>' . $columnTitle . '</th>';
    }
    echo '</tr>';
    
    // Bulk of the table
    foreach ($table as $rowTitle => $row) {
        echo '<tr>';
        echo '<th>' . $rowTitle . '</th>';
        foreach ($columns as $columnTitle => $junk) {
            if (isset($row[$columnTitle]) {
                echo '<td>' . $row[$columnTitle] . '</td>';
            } else {
                // Handle sparse tables gracefully.
                echo '<td>&nbsp;</td>';
            }
        }
        echo '</tr>';
    }
    echo '</table>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of two dimensional Arrays. I want to create a new
[I have some code to create a JSON array. In this code I am
I have two arrays a={a,b,c,d} b={1,2,3,4} now I want to create a 3rd array
Consider I have an array of elements out of which I want to create
Hi I want to create a JSON array. I have tried using: JSONArray jArray
I have an array of arrays that I want to use KVC on (at
I have an two dimension array that contains strings and want to create a
Suppose I have an immutable NSArray and want to create several sub-arrays. I could
I want to dynamically create arrays of arrays and I have no clue how
I have an array of arrays of data. so the basic format is $sheet

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.