Skip to content

Feature rich, fast and flexible PHP library for rendering table data as nice text tables.

License

Notifications You must be signed in to change notification settings

MarcinOrlowski/php-text-table

Repository files navigation

Text Table

..######.#####.##...##.######...######...#....#####..##....#####..
....##...##.....##.##....##.......##....###...##..##.##....##.....
....##...##......###.....##.......##...##.##..##..##.##....##.....
....##...####.....#......##.......##..##...##.#####..##....####...
....##...##......###.....##.......##..#######.##..##.##....##.....
....##...##.....##.##....##.......##..##...##.##..##.##....##.....
....##...#####.##...##...##.......##..##...##.#####..#####.#####..

Fast and flexible PHP library for text tables.

Latest Stable Version Total Downloads License PHP Version Require

There's also a Python version of this library.


Features

  1. Production ready,
  2. Easy to use,
  3. No additional dependencies,
  4. Documented.

Usage examples

NOTE: For proper rendering in environments like web browsers, ensure you are using a monospace font or wrap the output in <pre> tags.

$table = new TextTable(['ID', 'NAME', 'SCORE']);
$table->addRows([
    [1, 'John', 12],
    [2, 'Tommy', 15],
]);
echo $table->renderAsString();

would produce nice text table:

┌────┬───────┬───────┐
│ IDNAMESCORE │
├────┼───────┼───────┤
│ 1  │ John  │ 12    │
│ 2  │ Tommy │ 15    │
└────┴───────┴───────┘

Check docs for more usage examples.


License

  • Written and copyrighted ©2022-2025 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
  • Text Table is open-sourced software licensed under the MIT license

About

Feature rich, fast and flexible PHP library for rendering table data as nice text tables.

Resources

License

Contributing

Stars

Watchers

Forks

Languages