dongqiao1888
2016-04-12 10:54
浏览 75
已采纳

如何从magento中的数组中获取单个对象值?

i am trying to calculate shipping charge and i am getting a response from REST API. i want to get return the value of "delivery_charges" form response array?

Array
(
[response] => Array
    (
        [delivery_charges] => 41
        [return_charges] => 83
        [all_charges] => Array
            (
                [DL] => 32
                [FS] => 30
                [DTO] => 0
                [RTO] => 32
                [ST] => 14.5
                [COD] => 0
                [TDS] => 0
                [CARD] => 0
                [CNC] => 0
            )

        [canc_charges] => 0
        [pickup_charges] => 0
        [params] => Array
            (
                [md] => E
                [pt] => prepaid
                [cl] => xxxxxxx
                [o_pin] => 560076
                [d_pin] => 560062
                [token] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                [gm] => 100
                [d_city] => Bangalore
                [o_city] => Bangalore
            )

    )

)

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douyi1855 2016-04-12 13:00
    已采纳

    i got answer by just using

    return $shipping_charge['response']['delivery_charges'];
    
    已采纳该答案
    打赏 评论
  • dpswo40440 2016-04-19 17:30

    You need to simply add the following at the end. If $shipping_charge is the array then write:

    return $shipping_charge['response']['delivery_charges'];

    打赏 评论

相关推荐 更多相似问题