The Ds\Sequence::get() function is an inbuilt function in PHP which returns the value at given index.
Syntax:
mixed abstract public Ds\Sequence::get ( int $index )
Parameter: This function accepts single parameter $index which holds the index to access element.
Return value: This function returns the value at given index.
Below programs illustrate the Ds\Sequence::get() function in PHP:
Program 1:
<?php // Create new sequence $seq = new \Ds\Vector(["G", "E", "E", "K", "S", "1", "2", 1, 2, 3, 4]); // Use get() function var_dump($seq->get(0)); // Use get() function var_dump($seq->get(1)); // Use get() function var_dump($seq->get(10)); // Use get() function var_dump($seq->get(5)); // Use get() function var_dump($seq->get(7)); ?> |
Output:
string(1) "G" string(1) "E" int(4) string(1) "1" int(1)
Program 2:
<?php // Create new sequence $seq = new \Ds\Vector(["G", "E", "E", "K", "S", "1", "2", 1, 2, 3, 4]); // Declare an index array $arr = array (0, 1, 4, 6, 8, 5); // Loop run for every array element foreach ($arr as $val) { // Use get() function var_dump($seq->get($val)); } ?> |
Output:
string(1) "G" string(1) "E" string(1) "S" string(1) "2" int(2) string(1) "1"
Reference: http://php.net/manual/en/ds-sequence.get.php
Recommended Posts:
- How to Check a Function is a Generator Function or not using JavaScript ?
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- p5.js | arc() Function
- CSS | url() Function
- p5.js | nfp() Function
- p5.js | nfc() function
- p5.js | nf() Function
- D3.js | d3.map.set() Function
- PHP | dir() Function
- PHP | key() Function
- PHP | pos() Function
- PHP | Ds\Set contains() Function
- D3.js | d3.map.has() Function
- D3.js zip() Function
- D3.js | d3.map.get() Function
- p5.js | nfs() Function
- PHP | pi( ) Function
- D3.js | d3.sum() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.


