Foreach Loop not passing all values as expected
<p>I am trying to loop through an array comprised of IP addresses collected from a text file. The ultimate goal of this is to retrieve the host name for each IP. My problem is I am only getting results from the last IP in the array. I figured it would be pretty simple, but I am clearly missing something.</p>

<pre><code>&lt;?php
$thefile = 'myfile';
$arr = file($thefile.".txt");

foreach ($arr as $data) {
echo $hostname = gethostbyaddr($data);" &lt;br&gt;";
?&gt;
</code></pre>

<p>The text file contains several IP's that I know have associated names, but I get </p>

<p>"Warning: gethostbyaddr() [function.gethostbyaddr]: Address is not a valid IPv4 or IPv6 address in..."<br>
 for every instance but the last, which returns the correct results. Thanks for any help.</p>
