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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:20:12+00:00 2026-05-18T12:20:12+00:00

Are there any libraries I can use to pretty print tabular data(from php code)?

  • 0

Are there any libraries I can use to pretty print tabular data(from php code)?

What I mean is, if I have:


$headers = array("name", "surname", "email");
$data[0] = array("bill", "gates", "bill@microsoft.com");
$data[1] = array("steve", "jobs", "steve@apple.com");
/*...*/
pretty_print($headers, $data);

It will print my data neatly(preferably using tableless html code & css)?

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

    Why not just write your own?

    I wrote an example below. Note that I haven’t tested this – it’s the definition of “air code” so beware. Also, you could add checks to make sure count($rows) > 0 or to make sure count($rows) == count($headers) or whatever..

    The point is just that it isn’t that hard to throw something together:

    function displayTable($headings, $rows) {
      if !(is_array($headings) && is_array($data)) {
        return false; //or throw new exception.. whatever  
      }
    
      echo "<table>\n";
      echo "<thead>\n";
      echo "<tr>\n";
      foreach($headings as $heading) {
        echo "<th>" . $heading . "</th>\n";
      }
      echo "</tr>\n";
      echo "</thead>\n";
    
      echo "<tbody>"  
      foreach($data as $row) {
        echo "<tr>\n";
        foreach($row as $data) {
          echo "<td>" . $data . "<td>";
        }
        echo "</tr>\n";
      }
      echo "</tbody>\n";
      echo "</table>\n";
    }
    

    As a final note, why would you want to use HTML/CSS layouts rather than tables for this? Tables are for tabular data which this obviously is. This is their purpose!

    The trend against using tables is for using them to layout pages. They’re still quite valid for tabular data, and will be for the foreseeable future.

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

Sidebar

Related Questions

is there any Java validator libraries i can use to validate text input from
Are there any free libraries I can use in c# to download email attachments?
I program in Visual DataFlex. Are there any libraries that I can use to
Can we use OpenCV from Javascript? Is there such implementation? Is there any JS
Are there any tools/libraries on Windows that can help me tarck down the culprit?
I'd like to know if there are any libraries (preferably DateTime -esque) that can
Are there any libraries or tools specifically designed to help PHP programmers write Javascript?
Are there any libraries for in-browser javascript that provide the same flexibility/modularity/ease of use
Are there any libraries available that allow Android applications to transcode videos to different
Are there any libraries or utilities that will formally spell out the time? Examples:

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.