> Now I want to resolve the hostname from ip adresses:
> foreach ($aLines as $entry)
> { if ($entry->host == "")
> $entry->host = "Teststring";
> print $entry->host."\n"; // prints "Teststring"
> }
>
> // Testoutput
> foreach ($aLines as $entry)
> { print $entry->host."\n"; // prints empty string!
> }
>
> Why is host in the second loop empty again?
Advertising
Foreach returns a COPY of the contents... if you want to modify the
contents use the key... eg:
foreach ($aLines as $key=>$entry) {
if ($aLines[$key]->host == "") $aLines[$key]->host = "Teststring";
print $aLines[$key]->host."\n"; // prints "Teststring"
}
That way your altering the master array and not the copy
--
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software & Systems Engineer
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php