dcarbone/file-object-plus 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dcarbone/file-object-plus

最新稳定版本:0.4.0

Composer 安装命令:

composer require dcarbone/file-object-plus

包简介

A simple extension of the PHP \SplFileObject class

README 文档

README

A simple extension of the PHP class SplFileObject

Build status: Build Status

Basics:

This class is a very simple extension of the base PHP SplFileObject. As such, it has all the same functionality as the base class with a few minor additions.

Countable Interface

I have implemented the Countable interface into this class. It utilizes my FileHelper helper class to determine the count

To use, simply execute:

$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$count = count($fileObject);
echo $count;

To count lines that contain a term, execute:

$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$count = $fileObject->countLinesContaining('my term');
echo $count;

Pagination

This class also implements some very simple pagination methods, modeled closely to how you would specify returning a portion of a database table.

To get a portion of a file irrespective of line content:

$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$lines = $fileObject->paginateLines($offset, $limit);
var_dump($lines);

By default, blank lines are also returned. You may alternatively ignore these by passing in 4 parameters:

$fileObject = new \DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$search = null;
$includeEmpty = false;
$lines = $fileObject->paginateLines($offset, $limit, $search, $includeEmpty);
var_dump($lines);

If you wish to paginate through a file only matching lines that contain a certain term:

$fileObject = new \DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$search = 'my term';
$lines = $fileObject->paginateLines($offset, $limit, $search);

Note: When searching, the fourth parameter is ignored

Note: Both pagination functions currently reset the underlying SplFileObject's internal line pointer.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MPL-2.0
  • 更新时间: 2014-08-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固