How can the results of parsing a URL be stored in separate variables or arrays in PHP?

When parsing a URL in PHP, you can use the `parse_url()` function to break down the URL into its components such as scheme, host, path, etc. To store these components in separate variables or arrays, you can simply assign the values returned by `parse_url()` to individual variables or an associative array.

$url = "https://www.example.com/path/to/file?query=123";
$parsed_url = parse_url($url);

$scheme = $parsed_url['scheme'];
$host = $parsed_url['host'];
$path = $parsed_url['path'];
$query = $parsed_url['query'];

// Alternatively, store the components in an associative array
$url_components = [
    'scheme' => $parsed_url['scheme'],
    'host' => $parsed_url['host'],
    'path' => $parsed_url['path'],
    'query' => $parsed_url['query']
];