Are there any security concerns to consider when using PHP arrays in HTML links?

When using PHP arrays in HTML links, there is a security concern known as "HTML injection" where malicious users can inject code into the link that can execute harmful actions on the user's browser. To prevent this, it is important to properly sanitize the array values before outputting them in the HTML link.

<?php
// Example of sanitizing array values before using them in HTML links
$myArray = array(
    'page' => 'home',
    'id' => 123
);

$sanitizedArray = array_map('htmlspecialchars', $myArray);

echo '<a href="example.php?page=' . $sanitizedArray['page'] . '&id=' . $sanitizedArray['id'] . '">Link</a>';
?>