mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22: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 mixed $value
|
||||||
* @param null $key
|
* @param miexed $key
|
||||||
* @return int
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unshift($value, $key = null)
|
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