[請益] stdClass訪問變數

看板PHP作者 (基本上我是個演員)時間15年前 (2010/09/06 13:03), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
請問Web Service呼叫時 stdClass裡面有Array還有stdclass 請問怎麼分別取到最裡面變數 birth?? 使用指標方法 $result->API-getFunAResult 會有錯誤..是因為"-"的關係嗎? 請指教!! stdClass Object ( [API-getFunAResult] => stdClass Object ( [statusResult] => stdClass Object ( [id] => 1001 [name] => Sam ) [statusDetailList] => stdClass Object ( [myStatus] => Array ( [0] => stdClass Object ( [birth] => 701010 [log] => ok ) [1] => stdClass Object ( [birth] => 720101 [log] => ok ) ) ) ) ) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.110.17.137

09/06 13:06, , 1F
$result->{'API-getFunAResult'}->{'ooo'}->{'xxx'} ?
09/06 13:06, 1F
※ 編輯: RWA 來自: 140.110.17.137 (09/06 13:15)

09/06 14:02, , 2F
謝謝,請問可以用foreach來做到嗎?
09/06 14:02, 2F

09/06 14:19, , 3F
當然可以用foreach
09/06 14:19, 3F

09/06 20:34, , 4F
這種狀況最適合用foreach
09/06 20:34, 4F
文章代碼(AID): #1CX7O-O3 (PHP)
文章代碼(AID): #1CX7O-O3 (PHP)