To find the range (minimum and maximum values) of all the keys in a PHP map (associative array), you can use the min
and max
functions with the array_keys
function. Here's an example code snippet:
main.php290 chars14 lines
In this example, we first create a map (associative array) with some values. Then, we use the array_keys
function to get an array of all the keys in the map. Finally, we use the min
and max
functions to find the minimum and maximum keys in the keys
array.
Note that the min
and max
functions work with strings as well as numbers, so they can be used to find the range of any keys in the map.
gistlibby LogSnag