各位大侠,现在我有个XML文件,读到一个数组里面。 我想通过数组的键来表明XML的结构。
假设我的XML 数组是
Array
(
    [ShipmentInformationResponse] => Array
        (
            [OrderHeader] => Array
                (
                    [OrderNumber] => 11828
                    [Keycode] => 10110
                    [KeyedDate] => 2003-06-04 23:08:00
                    [TotalDiscount] => 0.00
                    [Balance] => 0.00
                    [TotalPaid] => 29.43
                    [TotalAmount] => 29.43
                    [OrderDate] => 2003-06-04 23:08:00
                )            [ShippingInformation] => Array
                (
                    [Shipment] => Array
                        (
                            [TotalLines] => 1
                            [File] => BO Test File                            
                            [TotalUnits] => 1
                            [ShipDate] => 2004-09-28
                            [ShipmentNumber] => 11828-1
                            [TotalWeight] => 30.00
                            [TotalShippingWeight] => 0.00
                            [Width] => 0.00
                            [Height] => 0.00
                            [Depth] => 0.00
                        )
                )
        )
)                        
   我如何能得到 OrderNumber 是从ShipmentInformationResponse -> OrderHeader -> OrderNumber 来的,
而TotalUnits 是从 ShipmentInformationResponse -> ShippingInformation -> Shipment -> TotalUnits 来的?

解决方案 »

  1.   

    可能问题表述不清,我的目的是把这个数组表示成如下形式:ShipmentInformationResponse : OrderHeader : OrderNumber
    ...
    ShipmentInformationResponse : ShippingInformation : Shipment : TotalUnits然后存到数据库里, 怎么才能得到上面的字符串那?
      

  2.   


    //没太明白意思,不过序列化数组对象可以么?,存在一个字段里,需要的时候,解序列化
    $myStr = serialize(array('a' => 'A', 'b' => 'B', 'c' => array('c', 'C')));
    echo $myStr;echo '<br />';print_r(unserialize($myStr));
      

  3.   


    我想做的是将XML的结构存到数据库里。