i need help in creating skip rules
i have array of 15rows,need to skip few rows from the array.(skip values is provide by the user)
im facing issues in array skip,
if user provides 1 skip only 1 row need to deleted but below function 2 rows are getting deleted
CASES : user1 wants to skip 2 rows,user2 wants to skip 1 row from given 15 rows
2 skip deleting 3 rows, 1 skip deletes 2 rows
function array_delete($idx, $array) {
for ($i = 0; $i <= $idx; $i++) {
unset($array[$i]);
}
return (is_array($array)) ? array_values($array) : null;
}
$numberSkip = 1;
$skipnumber = $skipnumber - $numberSkip;
$Arrayvalue = array_delete($skipnumber, $Array);
Change
into
Using
<=makes your loop run exactly one time too much: if$idx = 1then the loop will run for$i = 0and$i = 1. Changing<=into<will solve this problem and will have your loop run the desired amount of times.