How can PHP be used to display downloads in categories with their corresponding category names?
To display downloads in categories with their corresponding category names using PHP, you can create an array that stores the downloads and their categories. Then, loop through the array to display each download under its respective category name.
<?php
// Define an array with downloads and their categories
$downloads = array(
'Category 1' => array('Download 1', 'Download 2'),
'Category 2' => array('Download 3', 'Download 4'),
'Category 3' => array('Download 5', 'Download 6')
);
// Loop through the array to display downloads under their respective category names
foreach ($downloads as $category => $downloadList) {
echo '<h2>' . $category . '</h2>';
echo '<ul>';
foreach ($downloadList as $download) {
echo '<li>' . $download . '</li>';
}
echo '</ul>';
}
?>