s-mcdonald/functions 问题修复 & 功能扩展

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

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

s-mcdonald/functions

最新稳定版本:0.3.0

Composer 安装命令:

composer require s-mcdonald/functions

包简介

assortment of php functions

README 文档

README

Source Source

Setup.

First install via composer, then import the function in the using statements. eg:

use function SamMcDonald\Functions\random_bool;

random_bool

random_bool() ? 'foo' : 'bar';

array_rand_bias

echo array_rand_bias($array);

For example, take the following array of names;

$myarray = [
    'David',
    'Matthew',
     ...
    'George',
];

There is a descending trend in the names from the start of the index such as David. So David will be picked mostly, then Mathew and so on until the last element.

array_entry_exist

if (array_entry_exist($array, 'foo', 'bar')) {...}

// Which is a more convenient way of typing 
if (isset($array['foo']) && $array['foo'] === 'bar') {}

array_rand_pluck

$randomValue = array_rand_pluck($array);

// Alternative
$randomValue = $array[array_rand($array, 1)];

like_int

$like_int = "55";

if(like_int($like_int)) {
    echo "Yes this is could certainly be cast to an int.", PHP_EOL;
}

slugify

echo slugify("My friends long weekend at Bernie's");

Install via composer

composer require s-mcdonald/functions

Dependencies

  • Php 8.0

License

Functions is licensed under the terms of the MIT License (See LICENSE file for details).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-19