定制 fuitad/string-sequencer 二次开发

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

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

fuitad/string-sequencer

Composer 安装命令:

composer require fuitad/string-sequencer

包简介

PHP package that allows you to parse strings as sequences

README 文档

README

==============

PHP package that allows you to parse strings as sequences.

Installation

Require this package with Composer

composer require fuitad/string-sequencer

Usage

Import the class in your PHP file

use \Fuitad\StringSequencer;

static from() method:

use \Fuitad\StringSequencer;

$str = "http://www.google.com/page[:1:1:5:].html";
$result = StringSequencer::from($str);

Will return.

array:5 [
  0 => "http://www.google.com/page1.html"
  1 => "http://www.google.com/page2.html"
  2 => "http://www.google.com/page3.html"
  3 => "http://www.google.com/page4.html"
  4 => "http://www.google.com/page5.html"
]

static multi() method:

$str = "http://www.google.com/page[:1:1:5:]-[:20:5:40:].html";
$result = StringSequencer::multi($str);

Will return.

array:25 [
  0 => "http://www.google.com/page1-20.html"
  1 => "http://www.google.com/page1-25.html"
  2 => "http://www.google.com/page1-30.html"
  3 => "http://www.google.com/page1-35.html"
  4 => "http://www.google.com/page1-40.html"
  5 => "http://www.google.com/page2-20.html"
  6 => "http://www.google.com/page2-25.html"
  7 => "http://www.google.com/page2-30.html"
  8 => "http://www.google.com/page2-35.html"
  9 => "http://www.google.com/page2-40.html"
  10 => "http://www.google.com/page3-20.html"
  11 => "http://www.google.com/page3-25.html"
  12 => "http://www.google.com/page3-30.html"
  13 => "http://www.google.com/page3-35.html"
  14 => "http://www.google.com/page3-40.html"
  15 => "http://www.google.com/page4-20.html"
  16 => "http://www.google.com/page4-25.html"
  17 => "http://www.google.com/page4-30.html"
  18 => "http://www.google.com/page4-35.html"
  19 => "http://www.google.com/page4-40.html"
  20 => "http://www.google.com/page5-20.html"
  21 => "http://www.google.com/page5-25.html"
  22 => "http://www.google.com/page5-30.html"
  23 => "http://www.google.com/page5-35.html"
  24 => "http://www.google.com/page5-40.html"
]

Formatting

You can also add a sprintf compatible pattern to format the output.

$str = "http://www.google.com/page[:1:1:5:%02d:].html";
$result = StringSequencer::from($str);

Will return

array:5 [
  0 => "http://www.google.com/page01.html"
  1 => "http://www.google.com/page02.html"
  2 => "http://www.google.com/page03.html"
  3 => "http://www.google.com/page04.html"
  4 => "http://www.google.com/page05.html"
]

Back Reference

If you need to have the same iteration done multiple times in a string (versus having different iterations performed on a string), you can use back references. Keep in mind that while the syntax kinda looks like regular expression back references, it is not.

$str = "http://www.google.com/page[:1:1:5:%02d:]/[\\1].html";
$result = StringSequencer::from($str);

Will return.

array:5 [
  0 => "http://www.google.com/page1/1.html"
  1 => "http://www.google.com/page2/2.html"
  2 => "http://www.google.com/page3/3.html"
  3 => "http://www.google.com/page4/4.html"
  4 => "http://www.google.com/page5/5.html"
]

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固