diff --git a/library/think/Collection.php b/library/think/Collection.php index d88c3183..3fcba5cd 100644 --- a/library/think/Collection.php +++ b/library/think/Collection.php @@ -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; + } + } + /** * 给每个元素执行个回调 *