Ich habe ein Array im Bibliotheksverwaltungssystem, das einen Benutzer auf dem ersten Index hat, Bücher, die diesem Benutzer auf dem nächsten Index zugewiesen sind, und dann Details über Bücher, die so zugeordnet sind.PHP: Mehrdimensionales Array durchqueren
das ist, was ich in Tabellenform
Array
(
[user] => Array
(
[0] => stdClass Object
(
[id] => 5
[name] =>
[email] => [email protected]
[password] => test
[role] =>
[status] => 1
)
)
[books] => Array
(
[0] => stdClass Object
(
[id] => 1
[user_id] => 5
[book_id] => 1
[date_issue] => 2016-07-24 00:00:00
[date_return] => 2016-07-25 00:00:00
)
[1] => stdClass Object
(
[id] => 2
[user_id] => 5
[book_id] => 2
[date_issue] => 2016-07-24 00:00:00
[date_return] => 2016-07-25 00:00:00
)
[2] => stdClass Object
(
[id] => 3
[user_id] => 5
[book_id] => 1
[date_issue] => 2016-07-25 00:00:00
[date_return] => 2016-07-25 00:00:00
)
)
[bookdata] => Array
(
[0] => Array
(
[0] => stdClass Object
(
[id] => 1
[title] => PHP Made Easy
[author] => Dietel & Dietel
[serial_no] => 232323
[qty] => 9
[row_no] => 1
[col_no] => 2
[status] => 1
[category_id] => 1
[description] => This is a book about php
)
)
[1] => Array
(
[0] => stdClass Object
(
[id] => 2
[title] => C++
[author] => Dietel & Dietel
[serial_no] => 232323
[qty] => 9
[row_no] => 1
[col_no] => 2
[status] => 1
[category_id] => 1
[description] => This is a book about c++
)
)
[2] => Array
(
[0] => stdClass Object
(
[id] => 1
[title] => PHP Made Easy
[author] => Dietel & Dietel
[serial_no] => 232323
[qty] => 9
[row_no] => 1
[col_no] => 2
[status] => 1
[category_id] => 1
[description] => This is a book about php
)
)
)
)
dies zeigen, müssen, wie ich versuche, wie diese
foreach ($data as $key=> $value) {
echo $key[$value]->id;
}
den Fehler i
erhalten zu analysierenBewertung: Warnung
Nachricht: Illegal Offset-Typ
Dateiname: views/history.php
Zeilennummer: 4
Bitte helfen Sie mir dieses Array
was meinst du mit "Parsing"? Was ist das erwartete Ergebnis? meinst du "traversing" stattdessen? – fantaghirocco
bitte posten endgültige Ausgabe möchten Sie –
Ich meine, ich muss diese Ergebnisse in HTML-Tabelle drucken – Sikander