samad/array-conversion
最新稳定版本:v1.0.0
Composer 安装命令:
composer require samad/array-conversion
包简介
PHP Library for converting associative arrays as html table, XML, JSON, CSV. Also add, remove or edit column can be possible.
关键字:
README 文档
README
PHP Library for converting associative arrays as html table, XML, JSON, CSV. Also add, remove or edit column can be possible.
Inspired by yajra/laravel-datatables
Installation
Install the library by composer with following command:
composer install samad/array-conversion
Documentation
An associative/ multidimensional array or object can be manipulate with this script. You can convert the array/ object to HTML table, CSV file, JSON or XML data.
Suppose, you have an array as like following:
$data = [ [ 'name' => 'Abdus Samad', 'email' => 'samadocpl@gmail.com' ], [ 'name' => 'Ibrahim Ahad', 'email' => 'ahad@gmail.com' ] ];
now, you can convert this $data as HTML table
$toTableInitiate = new ArrayConversion($data); $toTableInitiate->toTable()
also, this $data can be converted into following formats:
- CSV file
toCSV() - JSON format
toJson() - XML format
toXml()
Add, Edit or Remove column
You can add an extra column by using closure.
As like Action to each single array of $data
$addColumnToTable = new ArrayConversion($data); $addColumnToTable->addColumn('Action', function ($data) { return '<button class="btn btn-success btn-xs">Action</button>'; })->toTable();
or you can remove single/ multiple column from each single array
$removeColumnFromTable = new ArrayConversion($data); $removeColumnFromTable->removeColumn('email', 'name') ->toTable();
also, you can edit column from each single array
$editColumn = new ArrayConversion($data); $editColumn->editColumn('email', function ($data) { return 'Email: ' . $data['email']; })->toTable();
After installation this library, you will see a file index.php with details example.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 657
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-12