To find the values in a map or associative array in PHP, you can use a foreach loop to iterate through each key-value pair in the array and print out the value for each key. Here is an example:
main.php145 chars10 lines
This code will output the following:
main.php26 chars4 lines
In this example, we first define our associative array or map $myMap with three keys ("apple", "banana", and "orange") and their corresponding values (2, 4, and 6).
We then use a foreach loop to iterate through each key-value pair in the array. For each iteration of the loop, the variable $key will be set to the current key, and the variable $value will be set to the current value.
We then print out the key and value for each iteration using echo. The . operator is used to concatenate the strings together, and the <br> tag is used to add a line break between each key-value pair.
gistlibby LogSnag