s-mcdonald/functions
最新稳定版本:0.3.0
Composer 安装命令:
composer require s-mcdonald/functions
包简介
assortment of php functions
关键字:
README 文档
README
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
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-19