What is the purpose of the function display_data() in the PHP code provided?

The purpose of the function display_data() in the PHP code provided is to output the data stored in the $data variable in a formatted manner. The function loops through the array and echos out each key-value pair. To fix the issue and ensure that the data is displayed correctly, we need to properly define the $data variable before calling the display_data() function.

<?php
$data = array(
    "name" => "John Doe",
    "age" => 30,
    "email" => "johndoe@example.com"
);

function display_data($data) {
    foreach ($data as $key => $value) {
        echo $key . ": " . $value . "<br>";
    }
}

// Call the function to display the data
display_data($data);
?>