我正在使用php和html构建一个homelab仪表板。目前我正在尝试从数组中获取信息并将其显示在div中。数组中提供的信息是iframe的url以及高度和宽度调整。我的问题是如何检索此数组的特定元素,以便我可以正确显示它。
$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'
]
];
答案 0 :(得分:0)
假设您要访问该网址。你可以通过
来做到这一点echo $dl['dashlet1']['url'];
echo $dl['dashlet2']['url'];
等。
您也可以使用循环。
foreach( $dl as $key => $value ) {
echo($key . " " . $value['url']);
}