PHP。 array_column()类似于SimpleXMLElement对象

时间:2018-03-21 08:48:52

标签: php simplexml

object(SimpleXMLElement)[803]
public 'row' => 
array (size=13)
  0 => 
    object(SimpleXMLElement)[797]
      public '@attributes' => 
        array (size=4)
          'codeonimage' => string '01' (length=2)
          'name' => string 'Крышка' (length=12)
          'oem' => string '13711251885' (length=11)
          'ssd' => string '$HgsQRnNPF0d$' (length=174)
      public 'attribute' => 
        array (size=2)
          0 => 
            object(SimpleXMLElement)[813]
              public '@attributes' => 
                array (size=3)
                  'key' => string 'amount' (length=6)
                  'name' => string 'Количество' (length=20)
                  'value' => string '1' (length=1)
          1 => 
            object(SimpleXMLElement)[814]
              public '@attributes' => 
                array (size=3)
                  'key' => string 'end_of_production' (length=17)
                  'name' => string 'end_of_production' (length=17)
                  'value' => string 'Не производтся с: 19871116' (length=40)
...

我试图接受所有的' oem'每个SimpleXML元素的值,如:

   array_column($simpleXMLObject->row, 'oem');

......当然我收到了一个错误:

array_column() expects parameter 1 to be array, object given

完整搜索还有另一种选择。但也许还有一些更好的方法可以做到这一点?

0 个答案:

没有答案