【问题标题】:how to get the value of array?如何获取数组的值?
【发布时间】:2010-10-21 09:36:03
【问题描述】:

我想在这个数组中获取 productId 和 addressTypeID 的值: 大批 (

[0] => Array
    (
        [entityId] => 7100122
        [orderId] => 110631
        [createDate] => 2010-10-19T05:40:00
        [lastUpdateDate] => 2010-10-19T05:40:00
        [deleted] => 
        [products] => Array
            (
                [Product] => Array
                    (
                        [productId] => 674976
                        [productCode] => 
                        [productDescription] => testtest
                        [units] => 3
                    )

            )

        [addresses] => Array
            (
                [Address] => Array
                    (
                        [addressTypeID] => 8
                        [addressLine1] => Cebu, Ceity
                        [city] => City
                        [zipcode] => 6000
                        [state] => cebu
                        [countryCode] => PH
                    )

            )

    )

)

我怎样才能得到它的价值?

【问题讨论】:

    标签: php arrays loops


    【解决方案1】:

    喜欢:

    $myarray[0]['products']['Product']['productId']
    
    $myarray[0]['addresses']['Address']['addressTypeID']
    

    看更多

    http://php.net/manual/en/language.types.array.php

    【讨论】:

    • @rayss 请先阅读一些文档?!我们不是按需编码人员:P @Haim 你比我更有耐心,不过答案很好:)
    【解决方案2】:
    $product_id = $your_array['products']['Product']['productId'];
    
    $address_id = $your_array['addresses']['Address']['addressTypeID'];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-04
      相关资源
      最近更新 更多