承接 awssat/numbered-string-order 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

awssat/numbered-string-order

Composer 安装命令:

composer require awssat/numbered-string-order

包简介

Sort a string array based on the included numbers naturally.

README 文档

README

Latest Version on Packagist StyleCI Build Status

Sort an array of strings based on the included numbers naturally. An alternative to PHP built-in natsort function that's actually work.

Install

Via Composer

$ composer require awssat/numbered-string-order

Usage

Sort

//if you are using laravel, then instead use:
//$numberedStringOrder = app(Awssat\numberedStringOrder\numberedStringOrder::class);

$numberedStringOrder = new numberedStringOrder();

$numberedStringOrder->sort([
    'episode 5',
    'episode50',
    '499',
    'episode1',
    'episode two hundred',
    'episode one',
    'episode two',
    'episode eleven',
    'episode three'
]);
    

>> output: 
[
     "episode1",
     "episode one",
     "episode two",
     "episode three",
     "episode 5",
     "episode eleven",
     "episode50",
     "episode two hundred",
     499,
]
   

If you ask why not use the built-in function (natsort), then see the natsort output of the same example above to know why:

 //output of built-in function natsor(): 🤨
 [
     "499",
     "episode1",
     "episode 5",
     "episode50",
     "episode eleven",
     "episode one",
     "episode three",
     "episode two",
     "episode two hundred",
   ]

Get the numbers

If you want to use our internal numbers extracting method

$numberedStringOrder->getNumbers(['2digits', 'text1', 'three3', 'two cars', 'blank']);

>> output:
[
     "2digits" => 2,
     "text1" => "1",
     "three3" => "3",
     "two cars" => 2,
     "blank" => "blank",
]

Convert words to numbers

This package can also be helpful if you want to convert numerical words to numbers

new numberedStringOrder();
$numberedStringOrder->englishWordsToNumbers('one hundred twenty-three thousand four hundred fifty-six');
>> output: 123456

//to get arabic words to number use: arabicWordsToNumbers(...)

Test

composer test

Currently, it supports English and Arabic.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固