What are common reasons for the "php_network_getaddresses: gethostbyname failed" error when trying to read a webpage into an array using PHP?

The "php_network_getaddresses: gethostbyname failed" error occurs when PHP is unable to resolve the hostname of the webpage being read into an array. This can happen due to various reasons such as incorrect DNS settings, network connectivity issues, or the webpage being temporarily unavailable. To solve this issue, ensure that the hostname is correct and reachable, check the DNS settings, and verify the network connectivity.

<?php
$url = 'https://example.com/page.html';
$contents = file_get_contents($url);
if($contents === false){
    echo "Error reading webpage into array.";
} else {
    $array = explode("\n", $contents);
    print_r($array);
}
?>