How can PHP arrays be used in HTML links?

To use PHP arrays in HTML links, you can iterate over the array using a loop, and for each element in the array, create an HTML link using the value as the link text and the key as the URL. This way, you can dynamically generate multiple links based on the elements in the array.

<?php
$links = array(
    'Google' => 'https://www.google.com',
    'Facebook' => 'https://www.facebook.com',
    'Twitter' => 'https://www.twitter.com'
);

foreach ($links as $text => $url) {
    echo "<a href='$url'>$text</a><br>";
}
?>