0

i have read an xml file but it returns like this

Array
(
[0] => Array
    (
        [0] => SimpleXMLElement Object
            (
                [0] => 94351
            )
    )

[1] => Array
    (
        [0] => SimpleXMLElement Object
            (
                [0] => 94351
            )
    )

 )

this is the code i have writen to read from the xml file

$root = new SimpleXMLElement($xml);     
$cart = array();
foreach ($root->Docs as $Docs) {    
    $x = $Docs;
    $cart[] = array($x);
}
}

but i want my array to look like this failing to get bellow result. im not getting the bellow result. reason i want bellow result is to compare this array to another array

Array
(
[0] => Array
    (
        [0] => 94351
    )

[1] => Array
    (
        [0] => 94352
    )

)
random_user_name
  • 25,694
  • 7
  • 76
  • 115
kanishka
  • 89
  • 2
  • 9

1 Answers1

0

For those, who'll open this question later Just cast SimpleXMLElement to string

E.g:

$cart[] = (string) $x;
Rulisp
  • 1,586
  • 1
  • 18
  • 30