To get the keys of a map in PHP, you can use the array_keys()
function. This function takes one argument, which is the array or map whose keys you want to retrieve, and returns an array containing all the keys of the map.
Here's an example usage:
main.php180 chars7 lines
In this example, the array_keys()
function is used to retrieve the keys of the $myMap
map, which are then printed to the console using print_r()
.
Note that if you want to retrieve only the unique keys of a map, you can pass in the ARRAY_UNIQUE
flag as a second argument to the array_keys()
function:
main.php214 chars7 lines
In this example, the ARRAY_UNIQUE
flag is used to retrieve only the unique keys of the $myMap
map.
gistlibby LogSnag