How can arrays be used in PHP to manipulate and display parts of a URL?

Arrays can be used in PHP to manipulate and display parts of a URL by breaking down the URL into its component parts using the `parse_url()` function. This function returns an associative array containing the various components of the URL such as the scheme, host, path, query, etc. Once the URL is parsed into an array, you can easily access and manipulate specific parts of the URL as needed.

$url = "https://www.example.com/page?param1=value1&param2=value2";
$url_parts = parse_url($url);

echo "Scheme: " . $url_parts['scheme'] . "<br>";
echo "Host: " . $url_parts['host'] . "<br>";
echo "Path: " . $url_parts['path'] . "<br>";

$query_params = [];
parse_str($url_parts['query'], $query_params);
echo "Query Parameters: <br>";
foreach ($query_params as $key => $value) {
    echo $key . ": " . $value . "<br>";
}