定制 oliverde8/fixed-width-file 二次开发

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

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

oliverde8/fixed-width-file

最新稳定版本:1.0.0

Composer 安装命令:

composer require oliverde8/fixed-width-file

包简介

Read and Write fixed width files

README 文档

README

Allows easy Read(not yet) and write of fixed width file.

Latest Stable Version Total Downloads Latest Unstable Version License

They are not nice, they are not easy to read but sometimes you just need them.

Howto

Firs let's create our file :

$writer = new Writer('/tmp/file.txt', ' ', STR_PAD_LEFT);

First parameter is the name of the file to write Then we have the padding character, by default it is empty. Last we have the direction to pad. right or left.

Now we will declare our columns :

$writer->getHeader()
    ->addColumn(4, 'year')
    ->addColumn(2, 'month')
    ->addColumn(2, 'day')
    ->addColumn(20, 'name')
    ->addColumn(100, 'description')

Once all this is done we can add data :

// First line
$data = array();
$data['year'] = 2016;
$data['month'] = 02;
$data['day'] = 15;
$data['description'] = "This is a description" ;
$writer->writeLine($data);

// second line
$data = array();
$data['year'] = 2016;
$data['month'] = 02;
$data['day'] = 1;
$data['description'] = "This is a description2" ;
$writer->writeLine($data);

End finish the write

$writer->terminate():

This will create a file looking like this :

20160215This is a description
201602 1This is a description2

Known Issues

  • None

The library will write every line as it comes, it was built for handling huge amounts of data and therfore doesen't have a mode where it can write everything at once at the end.

Todo

  • Support reading : The same way the files are written we can read them once we have the necessary header informations.

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固