Php 数组不是XML中的数组

Php 数组不是XML中的数组,php,arrays,xml,Php,Arrays,Xml,这里是我的XML代码部分 [390] => SimpleXMLElement Object ( [code] => 484 [barcode] => 9518 [supplier_code] => 9518 [name] => 9518 Bayan Kilot [cat1name] =

这里是我的XML代码部分

[390] => SimpleXMLElement Object
            (
                [code] => 484
                [barcode] => 9518
                [supplier_code] => 9518
                [name] => 9518 Bayan Kilot
                [cat1name] => Bayan Külot
                [cat1code] => 10
                [cat2name] => SimpleXMLElement Object
                    (
                    )

                [cat2code] => SimpleXMLElement Object
                    (
                    )

                [cat3name] => SimpleXMLElement Object
                    (
                    )

                [cat3code] => SimpleXMLElement Object
                    (
                    )

                [stock] => 39971
                [price_list] => 0,00
                [price_list_camping] => 13,50
                [currency] => TL
                [vat] => 8
                [brand] => Polat Yıldız
                [detail] => SimpleXMLElement Object
                    (
                    )

                [images] => SimpleXMLElement Object
                    (
                        [image] => http://shop.polatyildiz.com.tr/admin/uplfiles/B_67718135-14072013235822.jpg
                    )

                [bodies] => SimpleXMLElement Object
                    (
                        [body] => Array
                            (
                                [0] => 6 Adet -Battal
                                [1] => 6 Adet -Battal
                            )

                        [color_code] => Array
                            (
                                [0] => 840
                                [1] => 839
                            )

                        [stock] => Array
                            (
                                [0] => 19981
                                [1] => 19990
                            )

                    )

                [colors] => SimpleXMLElement Object
                    (
                        [color] => Array
                            (
                                [0] => KIRMIZI
                                [1] => SİYAH
                            )

                        [colorcode] => Array
                            (
                                [0] => 840
                                [1] => 839
                            )

                    )

            )
我的php代码在这里

$renkKodu = (int)$urun -> bodies -> color_code[$i];
if($renkKodu <= 0 || !$renkKodu){
    $ozellik_adi = $beden;
}else if($renkKodu > 0){
    if($urun -> colors -> color && $urun -> colors -> colorcode){
        $renkArray = $urun -> colors -> color;
        echo is_array($renkArray) ? 'Array' : 'Not array';
        $key = array_search($renkKodu, $urun -> colors -> colorcode);
    }else {
        $ozellik_adi = $beden;
    }
}
$renkKodu=(int)$urun->body->color_code[$i];
如果($renkKodu 0){
如果($urun->colors->color&&$urun->colors->colorcode){
$renkArray=$urun->colors->color;
echo是_数组($renkArray)?“数组”:“非数组”;
$key=array\u search($renkKodu,$urun->colors->colorcode);
}否则{
$ozellik_adi=$beden;
}
}

PHP返回“notarray”。我不能理解这一点。我在xml中看到了数组,但php说它不是数组。

SimpleXML对xml DOM节点对象进行了大量的自动映射和转换。因此,它确实不是一个数组。它应该是一个simplexmlement

以下是一个较小的示例:

$xml = new SimpleXmlElement(
  '<foo><child>one</child><child>two</child></foo>'
);

var_dump($xml);
var_dump(get_class($xml->child));
object(SimpleXMLElement)#1 (1) {
  ["child"]=>
  array(2) {
    [0]=>
    string(3) "one"
    [1]=>
    string(3) "two"
  }
}
string(16) "SimpleXMLElement"