I want to create my custom array slicing after certain indexes on each function call, I've defined the upperlimit and lower limit of the array indexes such that from starting limit to ending limit, I want to slice my array on each function call. I'm working in PHP and trying to get next array slices on each calling.
Im explaining it more by showing up my function,
function mycustomslicing($startingLimit = 0, $endingLimit = 10){
if ($startingLimit > 0)
$startingLimit = $startingLimit*$endingLimit;
for ($i=0; $i < $endingLimit ; $i++) {
$arr2[] = $arr1[$startingLimit+$i];
}
}
calling my function:
mycustomslicing(0, 10)
mycustomslicing(11, 20)
mycustomslicing(21,30)
My results:
i'm getting first iteration fine but onwards, it shows me index offsets warning.
My Desired results:
on mycustomslicing(0, 10) call:
$arr2 will be, all values from $arr1 from index 0 to 10.
on mycustomslicing(11, 20) call:
$arr2 will be, all values from $arr1 from index 11 to 20.
on mycustomslicing(21, 30) call:
$arr2 will be, all values from $arr1 from index 21 to 30.