我希望能够在表格中显示多维关联数组。数组由 Solarium API 创建,用于调试任何索引问题。每个数组都有不同数量的数组和键。
我希望它以一种可以与任何数字或数组和键一起使用的方式保持它。我开始使用 foreach 循环,但我被困在这一点上。我该怎么做呢?
我到目前为止的代码:
foreach ($metadatas as $metadata) {
foreach($metadata as $type => $data) {
echo '<tr>';
echo '<td>'.$type.'</td>';
echo '<td>'.$data.'</td>';
echo '</tr>';
}
}
这是我使用 print_r() 得到的数组:
Solarium\QueryType\Extract\Query Object
(
[options:protected] => Array
(
[handler] => update/extract
[resultclass] => Solarium\QueryType\Extract\Result
[documentclass] => Solarium\QueryType\Update\Query\Document\Document
[omitheader] =>
[extractonly] =>
[uprefix] => ignored_
[commit] => 1
[file] => http://url.com/branch/files/2015/03/Client-Feedback-Form.doc
[document] => Solarium\QueryType\Update\Query\Document\Document Object
(
[boost:protected] =>
[modifiers:protected] => Array
(
)
[key:protected] =>
[fieldBoosts:protected] => Array
(
[id] =>
[site] =>
[description] =>
[url] =>
[title] =>
)
[version:protected] =>
[helper:protected] => Solarium\Core\Query\Helper Object
(
[placeHolderPattern:protected] => /%(L|P|T|)([0-9]+)%/i
[assembleParts:protected] =>
[derefencedParamsLastKey:protected] => 0
[query:protected] => Solarium\QueryType\Update\Query\Document\Document Object
*RECURSION*
)
[filterControlCharacters:protected] => 1
[fields:protected] => Array
(
[id] => 227-7653
[site] => Branch Name
[description] =>
[url] => http://url.ca/branch/files/2015/03/Client-Feedback-Form.doc
[title] => Client Feedback Form
)
)
)
[fieldMappings:protected] => Array
(
[content_type] => type
[author] => authors
[last_modified] => lastModifiedDate
[creation_date] => creationDate
[content] => content
)
[helper:protected] =>
[params:protected] => Array
(
)
)