top-think / think-helper Goto Github PK
View Code? Open in Web Editor NEWthinkphp常用的助手类 助手函数
License: Apache License 2.0
thinkphp常用的助手类 助手函数
License: Apache License 2.0
字符串加一个函数可以给名字加* 的,列入我叫:王大明 自定义加*后 可以 ×大× 或者是×大明、××明、王×× 等等。
think-helper/src/Collection.php
Line 145 in f98e3ad
这个写法有点问题,和求差集的一样了
// 获取7天前零点到昨日结束的时间戳
Time::dayToNow(7, true);
改为:
Time::dayToNow(7, false); // 这个才是获取7天前零点到昨日结束的时间戳
Time::week() 返回的并不是本周开始和结束的时间戳。
而是 下周一的时间戳和本周结束的时间戳。
通过composer update从1.0.7更新到3.0.0后,Time.php不见了。
password_verify(): Passing null to parameter #2 ($hash) of type string is deprecated
是否为bug
为什么session.php配置store为redis,序列化参数也改为'serialize'=>['json_encode', 'json_decode']之后,居然无法使用验证函数,请问这算是BUG吗, 报错:password_verify(): Passing null to parameter #2 ($hash) of type string is deprecated
// /vendor/topthink/think-captcha/src/Captcha.php
将 $key = $this->session->get('captcha.key');
改成
$arr = $this->session->get('captcha');
$key = $arr->key;
就可以了
修改了一下代码,麻烦大佬修复一下。
文件: /vendor/topthink/think-helper/src/helper/Arr.php
方法: public static function get($array, $key, $default = null)
修改:
if (is_object($array[$segment])) {
$array = (array) $array[$segment];
} else {
$array = $array[$segment];
}
/**
* 汇总某个子集相同的到同一维
* @param array $array 输入的数组
* @param string $column 判断相同值的字段名
* @return array
*/
public static function gather($array, $column)
{
$data = [];
if ($array) {
foreach ($array as $item) {
if (!is_array($item) || !self::exists($item, $column)) return [];
$data[$item[$column]][] = $item;
}
}
return $data;
}
$data = [
['id' => 2, 'aid' => 3, 'cid' => 9],
['id' => 2, 'aid' => 5, 'cid' => 11],
];
var_dump(Arr::gather($data, 'id'));
结果
array:1 [
2 => array:2 [
0 => array:3 [
"id" => 2
"aid" => 3
"cid" => 9
]
1 => array:3 [
"id" => 2
"aid" => 5
"cid" => 11
]
]
]
希望Arr类可添加中文注释
昨日的开始结束时间的写法没有考虑到,跨月的情况。
上个月的开始结束时间的写法没有考虑到,跨年的情况。
{
"name": "topthink/think-queue",
"description": "The ThinkPHP5 Queue Package",
"type": "think-extend",
"authors": [
{
"name": "yunwuxin",
"email": "[email protected]"
}
],
"license": "Apache-2.0",
"autoload": {
"psr-4": {
"think\\": "src"
},
"files": [
"src/common.php"
]
},
"require": {
"topthink/think-helper": ">=1.0.4",
"topthink/think-installer": "^2.0",
"topthink/framework": "5.1.*"
},
"extra": {
"think-config": {
"queue": "src/config.php"
}
}
}
时间函数可以增加这些吗
public function order(string $field, string $order = 'asc')
{
return $this->sort(function ($a, $b) use ($field, $order) {
$fieldA = $a[$field] ?? null;
$fieldB = $b[$field] ?? null;
//
return 'desc' == strtolower($order) ? intval($fieldB > $fieldA) : intval($fieldA > $fieldB);
});
}
代码中结果,只有0和1,没有-1得
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.