Syntax:public DsDeque::remove ($index): mixed
Parameters: This function takes one parameter
$index, which contains the Deque index for which the element should be returned and removed.
Return value:this the function returns and removes the element at the specified index in Deque.The following programs illustrate the
Ds / Deque::delete()function in PHP:
Program 1:
// Declare deque
$deck
=
new
DsDeque ([10, 20, 30, 40, 50, 60]);
echo
(
" Elements of Deque "
);
// Show Deque elements
print_r (
$deck
);
echo
(
" Element at index 2: "
);
// Use the remove() function to remove
// element at index 2 and return it
print_r (
$deck
-> remove (2));
?>
Exit:Elements of Deque DsDeque Object ([0] = > 10 [1] = > 20 [2] = > 30 [3] = > 40 [4] = > 50 [5] = > 60) Element at index 2 : 30
Program 2:
// Declare deque
$deck
=
new
DsDeque ([
"engineer"
,
"for"
,
"engineer"
]);
echo
(
" Elements of Deque "
);
// Show Deque elements
print_r (
$deck
);
echo
(
" Element at index 1: "
);
// Use the remove() function to remove
// element at index 2 and return it
print_r (
$deck
-> remove (1));
?>
Exit:Elements of Deque DsDeque Object ([0] = > engineer [1] = > for [2] = > engineer) Element at index 1: for
Link: http://php.net/manual/en/ds-deque.remove.php