2014-04-03 93 views
-1
Array 
    (
     [1] => stdClass Object 
      (
       [position] => 1 
       [priority] => 1 
       [percentage] => 100 
      ) 
     [131] => stdClass Object 
      (
       [position] => 11 
       [priority] => 12 
       [percentage] => 80 
      ) 


    ) 

這是我的對象數組。獲得精確鍵的對象數組對象

爲什麼我不能像這樣得到對象:$ a = $ niz [1]?

+0

這對我來說很好。你可以做'var_dump($ a)'(或'var_dump($ niz [1])')併發布結果嗎? – Halcyon

+0

你可以 - 你得到什麼錯誤 – Steve

+0

消息:未定義的偏移:1這是錯誤。這非常奇怪 – consigliere

回答

1

將stdClass對象轉換爲php數組,以便以正常方式訪問它。

$niz = get_object_vars($niz); 
$a = $niz[1]; 

print_r($a); 
+0

它已經是PHP的數組對象 – consigliere