URL、高さ、幅などからiframeを書式設定しようとしています。ここに私がこれまで持っていたコードがあります。連想配列からのURLの書式設定
<div class="row"
<div class="col-md-6">
<div class="info-box twitter-bg">
<div>
<?php
if ($cfg_array['grafana'] == 'true') {
include 'dashlets.php';
foreach ($dl as $element) {
$url = $element["url"];
$height = $element["height"];
$width = $element["width"];
echo "<iframe src=\"" . $url . " \"" . "height=\"" . $height . " \"" . "width=\"" . $width . " \"" . "frameborder=\"0\">" . " " . "<\iframe>" . " ";
}
}
?>
</div>
</div>
</div>
ここは、dashlets.phpの配列です。
<?php
$dl = array(
'dashlet1' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=6',
'height' => '200',
'width' => '450'
),
'dashlet2' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=7',
'height' => '200',
'width' => '450'
),
'dashlet3' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=11',
'height' => '200',
'width' => '450'
),
'dashlet4' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=4',
'height' => '200',
'width' => '350'
),
'dashlet5' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=8',
'height' => '200',
'width' => '450'
),
'dashlet6' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=10',
'height' => '200',
'width' => '450'
),
'dashlet7' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=3',
'height' => '200',
'width' => '450'
),
'dashlet8' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=5',
'height' => '200',
'width' => '350'
)
);
私の問題は、いつループと最後の値内部以下に示すように、そのループブラケットの外側に配置されている場合、ループのみ配列から最初の値のいずれかを引くことです。 複数ののURLを配列アイテムからフォーマットし、それらを相互に水平なiframeに配置しようとしています。 私が間違っていることはありますか?
html divを含む完全なコードを追加するように編集されました。
すべてをdashlets.phpに移動しました。私はまだ最初の配列項目から返された結果しか得ていません。
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$dl = array(
'dashlet1' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=6',
'height' => '200',
'width' => '450'
),
'dashlet2' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=7',
'height' => '200',
'width' => '450'
),
'dashlet3' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=11',
'height' => '200',
'width' => '450'
),
'dashlet4' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=4',
'height' => '200',
'width' => '350'
),
'dashlet5' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=8',
'height' => '200',
'width' => '450'
),
'dashlet6' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=10',
'height' => '200',
'width' => '450'
),
'dashlet7' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=3',
'height' => '200',
'width' => '450'
),
'dashlet8' => array(
'url' => 'http://192.168.86.105:3000/dashboard-solo/db/home?panelId=5',
'height' => '200',
'width' => '350'
)
);
foreach ($dl as $element) {
$url = $element["url"];
$height = $element["height"];
$width = $element["width"];
echo "<iframe src=\"" . $url . "\"" . " height=\"" . $height . "\" " . "width=\"" . $width . "\"" . " frameborder=\"0\">" . " " . "<\iframe>" . "\n";
}
私のmain.phpでは、私のindex.phpビューポートから見ることができます。
<?php
$dl = array(
'dashlet1' => array(
'url' => 'http://1.1.1.1:3333/stuff/stuff?36',
'height' => '200',
'width' => '450'
),
'dashlet2' => array(
'url' => 'http://1.1.1.1:3333/stuff/stuff?37',
'height' => '200',
'width' => '450'
......
......
'width' => '450'
),
'dashlet8' =>array(
'url' => 'http://1.1.1.1:3333/stuff/stuff?35',
'height' => '200',
'width' => '350'
)
);
?>
そして、ループ内でエコーを置く:
<div class="row"
<div class="col-md-6">
<div class="info-box twitter-bg">
<div>
<?php
if ($cfg_array['grafana'] == 'true') {
include 'dashlets.php';
}
?>
</div>
</div>
</div>
PHPコードの結果はどうですか? –