Retrieving data from simplexml_load_file
Posted
by Kole Odd
on Stack Overflow
See other posts from Stack Overflow
or by Kole Odd
Published on 2010-03-08T05:44:56Z
Indexed on
2010/03/08
5:51 UTC
Read the original article
Hit count: 192
php
Working with the simplexml_load_file() function, I get a side effect. To understand what I mean, see this code:
$result = simplexml_load_file($xml_link);
$arr = array();
foreach ($result->element as $elem) {
$arr[] = $elem->number[0];
}
print_r($arr);
Output:
Array
(
[0] => SimpleXMLElement Object
(
[0] => 330411879136
)
[1] => SimpleXMLElement Object
(
[0] => 370346266228
)
[2] => SimpleXMLElement Object
(
[0] => 370346266223
)
)
How would I store data into the array so that output would look like so:
Array
(
[0] => 330411879136
[1] => 370346266228
[2] => 370346266223
)
© Stack Overflow or respective owner