定制 samad/array-conversion 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固