The Ds\Deque::insert() function is an inbuilt function in PHP which is used to insert the value at the given index in the Deque.
public Ds\Deque::insert( $index, $values ) : void
Parameters: This function accepts two parameter as mentioned above and described below:
- $index: This parameter holds the index at which element is to be inserted.
- $value: This parameter holds the value to be inserted into the given index in Deque.
Return Value: This function does not return any value.
Exception: This function throws OutOfRangeException if the Deque is empty.
Below programs illustrate the Ds\Deque::insert() function in PHP:
Elements in the Deque Ds\Deque Object (  => 1  => 2  => 3  => 4  => 5  => 6 ) Insert 10 at index 4 in the deque Ds\Deque Object (  => 1  => 2  => 3  => 4  => 10  => 5  => 6 )
Original Deque Ds\Deque Object (  => 1  => 2  => 3  => 4  => 5  => 6 ) Modified Deque Ds\Deque Object (  => 1  => 2  => 3  => 10  => 20  => 30  => 40  => 4  => 5  => 6 )
- PHP | Ds\Sequence insert() Function
- PHP | Ds\Vector insert() Function
- Insert string at specified position in PHP
- How to insert an item at the beginning of an array in PHP ?
- How to insert new row at a certain index in a table in jQuery ?
- How to insert line break before an element using CSS?
- How to insert HTML content into an iFrame using jQuery?
- Program to Insert new item in array on any position in PHP
- How to insert spaces/tabs in text using HTML/CSS?
- Java Servlet and JDBC Example | Insert data in MySQL
- What is the Efficient way to insert a number into a sorted array of numbers?
- How to get the function name inside a function in PHP ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.