Git Product home page Git Product logo

table's Introduction

HTML table builder

A PHP class for building an HTML table with data from a 2 dimensional array

Features

  • Use Table-Values from Arrays, Objects how PDO-Statement and Iterators
  • Add Title from Array, first Data Line or Array-Keys
  • Add Attributes how name, css-class for styling
  • Handles context switching for HTML
  • Formatting values with sprintf-Formats or date-Formats
  • One class and One File

Usage

require '/yourpath/Table.php';  //or autoload

$data = [  
  ['name' => 'A1', 'value' => 3],  
  ['name' => 'A12', 'value' => 6],  
  ['name' => 'A2','value' => 14],  
  ['name' => 'A14','value' => 7],  
]; 
$table = Table::create($data) 
  ->title(['Name','Wert']) 
  ->getHtml() 
; 
//Output
echo $table;

Demo and Test

http://jspit.de/check/phpcheck.table.php

Requirements

  • PHP 5.6 .. 8.2

Class-Info

Info Value
Declaration class Table
Datei Table.php
Date/Time modify File 2023-04-16 11:15:58
File-Size 7452 Byte
MD5 File d531c208b9a7bf2fb554d6e204c7bf18
Version 1.4
Date 2023-04-16

Public Methods

Methods and Parameter Description/Comments
final public function __construct($data) @param mixed $data : array, object, iterator
public static function create($data) create a instance
@param mixed $data : 2 dim array, iterator or tableArray Instance
@return static instance of tableArray
public function attribute($list) set html-Attributes
@param string $list: css-class-name or attribute-list
@return $this
public function title($title) set titles for columns
@param mixed $title
$title: Table::KEY, Table::FIRSTLINE, array or string with comma as delimiter
@return $this
public function format(array $format) set format for every column
may use sprintf-formats and date/datetime-formats
@param array $format:
@return $this
public function quoteSpecialChars($boolArr) set a mask if quote html special chars
@param array $boolArr: array with true/false (default all true)
@return $this
public function colClassName($className) @param string $className: className for Colums
@return $this
public function rowClassName($className) @param string $className: className for rows
@return $this
public function getHtml() render and get HTML
@return string : html
public function __toString() Return HTML for the table
@return string

Constants

Declaration/Name Value Description/Comments
const FIRSTLINE = 4; //title -> first Line data 4 title -> first Line data
const KEY = 8; //title -> keys from subarray 8 title -> keys from subarray

table's People

Contributors

jspit-de avatar

Stargazers

André Philip avatar

Watchers

André Philip avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.