mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
Collection类增加push方法
This commit is contained in:
@@ -167,9 +167,9 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
||||
|
||||
/**
|
||||
* 在数组开头插入一个元素
|
||||
* @param mixed $value
|
||||
* @param null $key
|
||||
* @return int
|
||||
* @param mixed $value
|
||||
* @param miexed $key
|
||||
* @return void
|
||||
*/
|
||||
public function unshift($value, $key = null)
|
||||
{
|
||||
@@ -180,6 +180,21 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在数组结尾插入一个元素
|
||||
* @param mixed $value
|
||||
* @param mixed $key
|
||||
* @return void
|
||||
*/
|
||||
public function push($value, $key = null)
|
||||
{
|
||||
if (is_null($key)) {
|
||||
$this->items[] = $value;
|
||||
} else {
|
||||
$this->items[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 给每个元素执行个回调
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user