Neos\Eel\Helper\ArrayHelper::push PHP Method

push() public method

Allows to push multiple elements at once:: Array.push(array, e1, e2)
public push ( array $array, mixed $element ) : array
$array array
$element mixed
return array The array with the inserted elements
    public function push(array $array, $element)
    {
        $elements = func_get_args();
        array_shift($elements);
        foreach ($elements as $element) {
            array_push($array, $element);
        }
        return $array;
    }

Usage Example

 /**
  * @test
  * @dataProvider pushExamples
  */
 public function pushWorks($array, $element1, $element2, $expected)
 {
     $helper = new ArrayHelper();
     $pushedArray = $helper->push($array, $element1, $element2);
     $this->assertEquals($expected, $pushedArray);
 }