licvido/array-to-table
最新稳定版本:v1.0.0
Composer 安装命令:
composer require licvido/array-to-table
包简介
PHP array of objects to table.
README 文档
README
PHP array to table
Converts a PHP array of objects/arrays to a summary table. Useful for debugging and examining data.
echo array_to_table($array);
Requirements
Package requires PHP 8.0 or higher.
Installation
The best way to install package is using Composer:
$ composer require licvido/array-to-table
Or simply copy the array_to_table() function from src/array_to_table.php into your project.
Usage
Pass an array of objects, arrays, or values to the array_to_table() function and print result.
// array of values $array = ['lorem', 'ipsum', 3, 4, 5, 'dolor', 7]; // or array of arrays without keys $array = [ [1, 2], [1, 2, 3], [1, 4, 3], [5, 6], ]; // or array of arrays with keys and values $array = [ ['A' => 1, 'B' => 2], ['A' => 3, 'B' => 4], ['A' => 5, 'B' => 6, 'C' => 7, 'D' => 8], ['E' => 9, 'F' => 0], ]; // or array of objects $array = [ (object) ['A' => 1, 'B' => 2], (object) ['A' => 3, 'B' => 4], (object) ['A' => 5, 'B' => 6, 'C' => 7, 'D' => 8], (object) ['E' => 9, 'F' => 0], ]; // or array of mixed arrays and objects $array = [ ['A' => 1, 'B' => 2], (object) ['A' => 3, 'B' => 4], ['A' => 5, 'B' => 6, 'C' => 7, 'D' => 8], (object) ['E' => 9, 'F' => 0], ]; // or array of objects from json $dummyData = json_decode(file_get_contents('https://dummyjson.com/users')); $array = $dummyData->users; // print table echo array_to_table($array);
Testing
composer test
License
This library is licensed under the MIT License - see the LICENSE.md file for details.
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-25
