PHP | Ds\Map keys() Function
Last Updated :
20 Aug, 2019
The Ds\Map::keys() function of PHP is used to get a set of keys of the current Map instance. The order of keys in the returned set is the same as that of the order of keys in the actual Map instance.
Syntax:
Ds\Set public Ds\Map::keys ( void )
Parameter: This function does not accepts any parameter.
Return value: It returns a set of Ds\Set containing all of the keys of the specified Map instance in the same order.
Below programs illustrate the Ds\Map::keys() function in PHP:
Program 1:
<?php
$map = new \Ds\Map([1 => "Geeks" , 2 => "for" ,
3 => "Geeks" ]);
print_r( $map ->keys());
?>
|
Output:
Ds\Set Object
(
[0] => 1
[1] => 2
[2] => 3
)
Program 2:
<?php
$map = new \Ds\Map([ "first" => "Geeks" , "second" => "for" ,
"third" => "Geeks" ]);
print_r( $map ->keys());
?>
|
Output:
Ds\Set Object
(
[0] => first
[1] => second
[2] => third
)
Reference: http://php.net/manual/en/ds-map.keys.php\
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...