可能重複:
Remove index key from Array for accessing to object?從陣列中取出指數
我需要能夠訪問term_id
價值,但我不知道用數組assossiated數量或索引。我怎樣才能訪問它?
我將訪問它像這樣$value->term_id
,現在我需要通過將數的值($value->[26]->term_id
)後才能訪問它。
Array
(
[26] => stdClass Object
(
[term_id] => 26
[name] => Night Life.
[slug] => shopping-and-night-life
[term_group] => 0
[term_taxonomy_id] => 28
[taxonomy] => map_categories
[description] => Most of the late night clubs, bars and pubs in Victoria are situated downtown. Here are a few to check out:
[parent] => 0
[count] => 6
[object_id] => 925
)
)
簡單的解決方案:'$ value = $ value [26]; echo $ value-> term_id;'這是因爲你有一個內部有一個對象的數組。 – phpisuber01
'stdClass'是_object_,所以用' - >' –
訪問點是他不知道26索引/// –