Retrieving data from simplexml_load_file
- by Kole Odd
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
)