PHP ASCII 表库
是否有用于在 PHP 中创建 ASCII表"的事实上的标准库?
Is there a de-facto standard library for creating ASCII "tables" in PHP?
我想要一些 PHP 代码,当处理数组或其他数据结构时,它会输出类似于 mysql 命令行客户端结果的表
I want some PHP code that, when handed an array or other data structure will output tables that look something like the mysql command line client's results
+--------+---------------------+----------------------------------+
| fld_id | fld_name | fld_email |
+--------+---------------------+----------------------------------+
| 1 | A value | another value |
| 2 | A value | |
| 3 | A value | another value |
+--------+---------------------+----------------------------------+
不是火箭科学,甚至不是计算机科学,而是有人已经解决的乏味科学.
Not rocket science, or even computer science, but certainly tedious science that someone's already solved.
推荐答案
虽然它不是事实上的标准,Zend_Text_Table
组件正是这样做的.
While it's not the defacto standard, the Zend_Text_Table
component of the Zend Framework does exactly this.
它具有高度可配置和模块化的额外好处;例如,它使您可以控制各种格式细节.此外,它遵守严格的 OOP 原则(如果这对您很重要).
It has the added bonus of being highly configurable and modular; for example it affords you control over all sorts of formatting details. Also, it adheres to strict OOP principals, if that matters to you.
虽然它是更大库的一部分这一事实可能令人生畏,但该组件是相当解耦的,我能看到的唯一依赖项是 Zend_Loader_PluginLoader
,因为它的可插拔渲染引擎.
While the fact that it is part of a larger library may be intimidating, the component is fairly decoupled, the only dependency I can see is on the Zend_Loader_PluginLoader
, for its pluggable rendering engine.
最重要的是,它完全支持 UTF-8.
Most importantly, it fully supports UTF-8.
相关文章