How can PHP functions be utilized effectively to organize and output data in a structured manner for HTML presentation?

To organize and output data in a structured manner for HTML presentation using PHP functions, you can create custom functions that format and display the data in the desired way. This can help keep your code clean, modular, and reusable, making it easier to maintain and update in the future.

<?php

// Function to format and output data in a structured manner
function displayData($data) {
    echo '<ul>';
    foreach ($data as $item) {
        echo '<li>' . $item . '</li>';
    }
    echo '</ul>';
}

// Sample data
$data = ['Item 1', 'Item 2', 'Item 3'];

// Output the data using the custom function
displayData($data);

?>