我有以下數組,它是來自對象的類型轉換的結果。我得到的數據陣列下面的輸出類型轉換對象數組後,如何將子數組[*屬性]提取到任何新的數組中
Array
(
[*table] => inspector_details
[*connection] =>
[*primaryKey] => id
[*perPage] => 15
[incrementing] => 1
[timestamps] => 1
[*attributes] => Array
(
[id] => 94
[firstname] => Aamir39
[address1] =>
[address2] =>
[city] =>
[state] =>
[is_frozen] => 1
[email] => [email protected]
[is_email_private] => 0
[status] => 2
[latitude] =>
[longitude] =>
[created_at] => 2016-07-12 15:40:14
[updated_at] => 2016-07-13 11:40:44
[zip] => 0
[company] => OTS
[website] =>
[phone] =>
[is_phone_private] => 0
[company_began_date] => 0000-00-00
[logo] =>
[freetext] =>
[lic_name] =>
[lic_id] =>
[lic_url] =>
)
[*original] => Array
(
[id] => 94
[firstname] => Aamir39
[address1] =>
[address2] =>
[city] =>
[state] =>
[is_frozen] => 1
[email] => [email protected]
[is_email_private] => 0
[status] => 2
[latitude] =>
[longitude] =>
[created_at] => 2016-07-12 15:40:14
[updated_at] => 2016-07-13 11:40:44
[zip] => 0
[company] => OTS
[website] =>
[phone] =>
[is_phone_private] => 0
[company_began_date] => 0000-00-00
[logo] =>
[freetext] =>
[lic_name] =>
[lic_id] =>
[lic_url] =>
)
[*relations] => Array
(
)
[*hidden] => Array
(
)
[*visible] => Array
(
)
[*appends] => Array
(
)
[*fillable] => Array
(
)
[*guarded] => Array
(
[0] => *
)
[*dates] => Array
(
)
[*dateFormat] =>
[*casts] => Array
(
)
[*touches] => Array
(
)
[*observables] => Array
(
)
[*with] => Array
(
)
[*morphClass] =>
[exists] => 1
[wasRecentlyCreated] =>
)
我想提取[*屬性]子陣列中的新陣列名爲$ errordata子[]。
我的代碼如下,
$emaildataarray = (array)$emaildata;
array_push($errordata, $emaildataarray['*attributes']);
,但它給我的錯誤,
Undefined index: *attributes
任何幫助深表感謝。謝謝。
是如何*屬性的陣列的一部分中描述當你'的var_dump($ emaildataarray)' – BeetleJuice
@BeetleJuice喜歡這張 [ 「*屬性」] =>數組 (25){ [ 「ID」] = > int(94).................... – Aamir
然後你的代碼'$ emaildataarray ['* attributes']'應該可以工作。當你的數據仍然是一個對象時,你如何訪問'* attributes'? – BeetleJuice