loandbeholdru/shorts 问题修复 & 功能扩展

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

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

loandbeholdru/shorts

Composer 安装命令:

composer require loandbeholdru/shorts

包简介

Couple useful functions to operate with arrays and strings

README 文档

README

Use this tool for simple operation with strings and arrays.

Installation

It's recommended that you use Composer to install shorts.

$ composer require loandbeholdru/shorts

TODO / in progress

Package include many functions which i use more than 5 years, but this README so poor.
Documentation in progress ...

Usage

Replaces the fields in the $payload text according to the $dict dictionary. ReGexp field template takes from $field regexp $dict is an associative array. Field names in $keys, field contents in $values

arrays::substfields(string $payload, array $dict, string $fieldregexp = "/#\{%s\}/")

Switch keys of assoc array to low reg:

arrays::lowkeys(array $payload)

Changes $payload to array. If $payload is array do it recursive:

arrays::always($payload)

Deep sorting and comparing two arrays:

arrays::isEqual(array $ar1, array $ar2)

Returns true if all array elements belong to the $type type:

arrays::is_array_of($payload, $sample, bool $anywayarray = false)

Combines an array of two different ones. Regardless of the length. Finishes off all $ by default:

arrays::args($names, $values, $default = null)

Recursively sorts the array by keys or by content (if it is ordinary):

arrays::sort(&$payload)

Defines the associativity of an array:

arrays::isAssoc($payload)

Returns an instance of a class made from an array, if the array contains information about the class in the field with the name: arrays::TYPE_KEY ("_type")

arrays::fromClassified($classified, $default = null)

Handles "fail" situations. If $default is a function, executes $default($data). If $default is an exception, it throws an exception. In other cases, it returns $default:

arrays::fail($data, $default)

Returns decoded JSON, acting in the same way as json_decode, only determines the validity of json. In case of invalid JSON returns either default or the result of default execution (or Exception):

arrays::valid_json($string, bool $assoc = true, $default = null)

First, drive everything to an array (over the entire depth), then to json, and then takes a hash:

arrays::deephash($payload, string $algo = 'ripemd128')

Last element:

arrays::last(array $payload)

First element:

arrays::first(array $payload)

Checks for the presence of a constant in the class or globally. $default responds:

arrays::ifDefined(string $classname, string $constname, $default = null)

Contributions

... are always welcome. Many times it is useful to just point out a use case the author have not thought about or come across.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固