我需要从数组中获取NID

时间:2012-06-29 06:07:48

标签: php

array(1) { 
            [0] => object(stdClass)#53 (14) 
                { 
                    ["cart_item_id"]=> string(2) "64" 
                    ["cart_id"]=> string(1) "1" 
                    ["nid"]=> string(3) "204" 
                    ["qty"]=> string(1) "1" 
                    "changed"]=> string(10) "1340948878" 
                    ["data"]=> array(3) 
                        { 
                            ["shippable"]=> string(1) "1" 
                            ["restrict_qty"]=> string(1) "0" 
                            ["module"]=> string(10) "uc_product" 
                        } 
                    ["title"]=> string(5) "songs" 
                    ["vid"]=> string(3) "204" 
                    ["cost"]=> string(9) "123.00000" 
                    ["price"]=> string(9) "123.00000" 
                    ["weight"]=> string(1) "0" 
                    ["weight_units"]=> string(2) "lb" 
                    ["module"]=> string(10) "uc_product" 
                    ["model"]=> string(1) "1" 
                } 
        }

请帮助如何只在新变量中获取nid值。

1 个答案:

答案 0 :(得分:1)

通过

$output = $array[0]->nid

通过->访问对象[index]

访问数组