-3
我正在使用php和html构建homelab仪表板。目前我正试图从数组中获取信息并将其显示在div中。数组中提供的信息是iframe的url以及高度和宽度调整。我的问题是如何检索此数组的特定元素,以便我可以正确显示它。如何使用PHP检索多维数组的特定元素
$dl = [
'dashlet1' => [
'url' => 'some random url',
'height' => 'height=200',
'width' => 'width=450'
],
'dashlet2' => [
'url' => 'another random url',
'height' => 'height=200',
"width" => 'width=450'
],
'dashlet3' => [
'url' => 'another random url',
'height' => 'height=200',
'width' => 'width=450'
],
'dashlet4' => [
'url' => 'another random url',
'height' => 'height=200',
'width' => 'width=350'
],
'dashlet5' => [
'url' => 'another random url',
'height' => 'height=200',
'width' => 'width=450'
],
'dashlet6' => [
'url' => 'another random url',
'height' => 'height=200',
'width' => 'width=450'
],
'dashlet7' => [
'url' => 'another random url',
'height' => 'height=200',
'width' => 'width=350'
],
'dashlet8' =>[
'url' => 'another random url',
'height' => 'height=200',
'width' => 'width=450'
]
];
http://php.net/manual/en/control-structures.foreach.php – AbraCadaver
开始读一本手册和[MCVE] –
为了得到一个特定的元素,例如,'$ DL ['dashlet6 '] [' URL']'。 [请参阅数组文档](http://php.net/manual/en/language.types.array.php#language.types.array.syntax.accessing)。 –