I'm looping through node values in my XML file, but I can't get the output as I need it. Below is the code that I'm working with.
PHP:
$xml = simplexml_load_file("file.xml") or die("Error: Cannot create object");
$result = array();
foreach($xml->picture as $item)
{
$result[] = $item->logo;
}
echo '<pre>';
print_r($result);
echo '</pre>';
Current output:
Array
(
[0] => SimpleXMLElement Object
(
[0] => img/a.jpg
)
[1] => SimpleXMLElement Object
(
[0] => img/b.jpg
)
[2] => SimpleXMLElement Object
(
[0] => img/c.jpg
)
...
)
Desired Output:
Array
(
[0] => a.jpg
[1] => b.jpg
[2] => c.jpg
...
)