Allows to give multiple replacements at once::
Array.splice(array, 3, 2, 'a', 'b')
public splice ( array $array, integer $offset, integer $length = 1, mixed $replacements = null ) : array | ||
$array | array | |
$offset | integer | Index of the first element to remove |
$length | integer | Number of elements to remove |
$replacements | mixed | Elements to insert instead of the removed range |
return | array | The array with removed and replaced elements |
/** * @test */ public function spliceNoReplacements() { $helper = new ArrayHelper(); $splicedArray = $helper->splice([0, 1, 2, 3, 4, 5], 2, 2); $this->assertEquals([0, 1, 4, 5], $splicedArray); }