Retrieve IP addresses with PHP's gethostbyname()
<p>Using the code below I've been able to open a <code>.csv</code> file with several domain names, which I then put in a PHP array and loop through. In the loop I call a function that returns the IP address of each domain (<code>gethostbyname()</code>). </p>

<p>However, when I execute this, I simply get the domain names echoed back to me. When I use this function on a single domain (i.e. not in a loop) I get the IP address as desired.</p>

<p>What's going wrong here? Is there some sort of in built limit or am I building the array wrong?</p>

<pre><code>&lt;?php

$urls = file('test.csv'); 

foreach($urls as $url){

    $ip = gethostbyname($url);
    echo $ip.'&lt;br/&gt;';
}

?&gt;
</code></pre>
