我有一個數組$的數據,這裏的print_r($data)
值:如何獲得一個數組元素
[ProductProperties] => Array
(
[ProductProperty] => Array
(
[0] => Array
(
[Additionaldescription] => microphone, blabla
)
[1] => Array
(
[interface] => USB 2.0
)
[2] => Array
(
[Model] => C310 HD
)
[3] => Array
(
[Manufacturer] => Logitech
)
[4] => Array
(
[Color] => Black
)
)
)
如果我想顯示「接口」的價值,我必須做這樣的:
echo $data['ProductProperties']['ProductProperty'][0]['interface'];
但在我的情況下,這些數字總是在變化,所以使用上述方法是不行的。我可以直接選擇「界面」值而不提及數字索引,例如:
echo $data['ProductProperties']['ProductProperty']['interface'];
在此先感謝。 (使用php 5.5)