This Is my array:
array(10) {
[0]=> string(29) "Cass Luxury Shapewear Bottoms"
[1]=> string(8) "xBhjsN9G"
[2]=> string(2) "20"
[3]=> string(57) "Cass Luxury Shapewear Bottoms. Multiple Styles Available."
[4]=> string(29) "cass-luxury-shapewear-bottoms"
[5]=> string(28) "Curabitur non nulla sit amet"
[6]=> string(8) "vjIhw8cw"
[7]=> string(3) "500"
[8]=> string(690) "posuere cubilia Curae; Donec velit neque."
[9]=> string(28) "curabitur-non-nulla-sit-amet"
}
remove this array:
[5]=> string(28) "Curabitur non nulla sit amet"
[6]=> string(8) "vjIhw8cw"
[7]=> string(3) "500"
[8]=> string(690) "posuere cubilia Curae; Donec velit neque."
[9]=> string(28) "curabitur-non-nulla-sit-amet"
Use unset()
to unset an array like this:
unset($array[5]); //if the index is 5
As an example:
<?php
$array = array(
array(1),
array(2)
);
echo "<pre>";
print_r($array);
unset($array[1]);
echo "<pre>";
print_r($array);
?>
Output:
Array
(
[0] => Array
(
[0] => 1
)
[1] => Array
(
[0] => 2
)
)
Array
(
[0] => Array
(
[0] => 1
)
)
We need to looping and delete by its index.
// $items is your array variable
for ($i = 0; $i < count($items); $i++) {
if ($i >= 5 && $i <= 9) {
unset($items[$i]);
}
}
print_r($items);
Hope it can help