Situatie
Given an array of elements, we have to delete an element from the array by using the unset() function.
Input : $arr = array(1, 2, 6, 7, 8, 9);
unset($arr[3]);
Output : Array
(
[0] => 1
[1] => 2
[2] => 6
[4] => 8
[5] => 9
)
Solutie
Pasi de urmat
<?php
$a = array(1, 8, 9, 7, 3, 5, 4, );
// unset command accepts 3rd index and
// thus removes the array element
// at that position
unset($a[5]);
print_r ($a);
?>
Output:
Array ( [0] => 1 [1] => 8 [2] => 9 [3] => 7 [4] => 3 [6] => 4 )
Leave A Comment?