What is the best way to output both the key names and values of an associative array in PHP?

When outputting both the key names and values of an associative array in PHP, you can use a foreach loop to iterate through the array and print out the keys and values. This allows you to easily display all the information contained within the array.

$array = array("key1" => "value1", "key2" => "value2", "key3" => "value3");

foreach ($array as $key => $value) {
    echo "Key: " . $key . ", Value: " . $value . "<br>";
}