splice()
The splice() method remove a portion of the array and replace it with something else
<?php use kim\present\utils\arrays\ArrayUtils;
$arrayUtils = ArrayUtils::from(range(1, 10));
$arrayUtils->splice(2);
// expected output: [3, 4, 5, 6, 7, 8, 9, 10]
$arrayUtils;
// expected output: [1, 2]
//Reset
$arrayUtils = ArrayUtils::from(range(1, 10));
$arrayUtils->splice(2, 4, "Hi", "Bye", "Oh");
// expected output: [3, 4, 5, 6]
$arrayUtils->splice(-4);
// expected output: [1, 2, "Hi", "Bye", "Oh", 7, 8, 9]Syntax
$arrayUtils->splice(int $offset, ?int $length = null, mixed ...$replacement) : ArrayUtils;Parameter
Return value
Prefixing
References
Last updated