定制 straylightagency/helpers 二次开发

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

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

straylightagency/helpers

最新稳定版本:v0.1.0

Composer 安装命令:

composer require straylightagency/helpers

包简介

Some raw and useful helpers functions

关键字:

README 文档

README

Just some raw and useful helpers functions.

Installation

Require this package with composer.

composer require straylightagency/helpers

API Documentation

Format a comma separated float "65,25" into a regular dotted float "65.25", useful for pricing.

price_format(num: mixed, decimals: int = 2, decimal_separator: ?string = ".", thousands_separator: ?string = "" ): float

Check if an int|float value is within a certain bound. If the value is in range it returns the value, if the value is not in range it returns the nearest bound.

clamp(value: int|float, min: int|float, max: int|float): float|int

Get the contents of a svg file, applying a class list on it before returning if $class_list is not null.

svg_get_contents(file_path: string, class_list: ?string = null): string

Convert iso code to emoji.

iso_to_emoji(code: string): string

Same as array_map but the callback get the key associated to the value.

array_map_keys(callback: ?callable, array: array): array

Do a preg_match_all using callback with patterns.

preg_match_callback_array(patterns: array, subject: string): array

Equivalent to array_diff but recursively.

array_recursive_diff(a: array, b: array):array

Remove the first item(s) of an array if values are empty.

array_clean_first(array $array): array

Remove the last item(s) of an array if values are empty.

array_clean_last(array $array): array

Ensure the value is an array, otherwise returns an empty array. Avoid foreach error when the value is not an expected array.

array_safe(array: mixed): array

Explode a content string into an array of multiple lines based on carriage return characters.

split_content(string $content): array

Remove the <p></p> tags on a text.

strip_p(string $string): string

Easy way to split a text after $limit words without cutting through the middle of a word.

text_excerpt(string $text, int $limit = 35, string $end = '...'): string

Return a valid Google map url using address information provided. Second parameter itinerary allows to return an itinerary path instead of a pin on the map.

google_map_url(address: array, itinerary: bool = false): string

Find the ID of a video from the Vimeo url. Return null if it failed.

vimeo_id(vimeo_url: string): ?int

Find the ID of a video from the YouTube url. Return null if it failed.

youtube_id(youtube_url: string): ?string

Requirement

PHP 8.3 or above

See also

Credits

License

The MIT License (MIT).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固