The Ds\Vector::insert() function is an inbuilt function in PHP which is used to insert the element into the vector at the given index.
void public Ds\Vector::insert( $index, $values )
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 which is to be inserted.
Return Value: This function does not return any value.
Exception: This function returns OutOfRangeException if the index is not valid.
Below programs illustrate the Ds\Vector::insert() function in PHP:
Ds\Vector Object (  => 1  => 2  => 4  => 5 ) Ds\Vector Object (  => 1  => 2  => 3  => 4  => 5 )
Ds\Vector Object (  => geeks  => for  => geeks ) Ds\Vector Object (  => geeks  => practice  => for  => geeks )
- PHP | Ds\Deque insert() Function
- PHP | Ds\Sequence 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 spaces/tabs in text using HTML/CSS?
- Program to Insert new item in array on any position in PHP
- How to insert HTML content into an iFrame using jQuery?
- What is the Efficient way to insert a number into a sorted array of numbers?
- Java Servlet and JDBC Example | Insert data in MySQL
- 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 firstname.lastname@example.org. 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.