Ben Ben - 1 year ago 125
PHP Question

PHP foreach not working XML

I don't really understand why this foreach is not working:

$url = "";
$xml = simplexml_load_file($url);

foreach($xml->result->name as $name)

echo $name;

it shows only the 1st row!

Answer Source

you have to loop $xml->result.

foreach($xml->result as $result)
    echo $result->name;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download