PHP | Ds\Sequence get() Function
Last Updated :
21 Aug, 2019
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
$seq = new \Ds\Vector([ "G" , "E" , "E" ,
"K" , "S" , "1" , "2" , 1, 2, 3, 4]);
var_dump( $seq ->get(0));
var_dump( $seq ->get(1));
var_dump( $seq ->get(10));
var_dump( $seq ->get(5));
var_dump( $seq ->get(7));
?>
|
Output:
string(1) "G"
string(1) "E"
int(4)
string(1) "1"
int(1)
Program 2:
<?php
$seq = new \Ds\Vector([ "G" , "E" , "E" ,
"K" , "S" , "1" , "2" , 1, 2, 3, 4]);
$arr = array (0, 1, 4, 6, 8, 5);
foreach ( $arr as $val ) {
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...