Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 关联数组和格式问题_Php_Html_Arrays - Fatal编程技术网

Php 关联数组和格式问题

Php 关联数组和格式问题,php,html,arrays,Php,Html,Arrays,我一直在尝试创建一个带有grafana嵌入式图形的仪表板。我在格式化它们时遇到了一些问题,我认为这是我编码错误的地方,但在这里调查并创建了一篇不同的帖子之后,我确认这应该并且确实正确地输出了我的所有Dashlet。我的问题是它没有显示它们,而是只显示数组中的第一个 我的代码: /* * To change this license header, choose License Headers in Project Properties. * To change this template f

我一直在尝试创建一个带有grafana嵌入式图形的仪表板。我在格式化它们时遇到了一些问题,我认为这是我编码错误的地方,但在这里调查并创建了一篇不同的帖子之后,我确认这应该并且确实正确地输出了我的所有Dashlet。我的问题是它没有显示它们,而是只显示数组中的第一个

我的代码:
/*
 * 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";
/*
*要更改此许可证标题,请在“项目属性”中选择“许可证标题”。
*要更改此模板文件,请选择工具|模板
*然后在编辑器中打开模板。
*/
$dl=数组
(
“dashlet1”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=6',
“高度”=>“200”,
“宽度”=>“450”
),
“dashlet2”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=7',
“高度”=>“200”,
“宽度”=>“450”
),
“dashlet3”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=11',
“高度”=>“200”,
“宽度”=>“450”
),
“dashlet4”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=4',
“高度”=>“200”,
“宽度”=>“350”
),
“dashlet5”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=8',
“高度”=>“200”,
“宽度”=>“450”
),
“dashlet6”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=10',
“高度”=>“200”,
“宽度”=>“450”
),
“dashlet7”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=3',
“高度”=>“200”,
“宽度”=>“450”
),
“dashlet8”=>数组(
'url'=>'http://192.168.86.105:3000/dashboard-solo/db/home?面板ID=5',
“高度”=>“200”,
“宽度”=>“350”
)
);
foreach($dl作为$element){
$url=$element[“url”];
$height=$element[“height”];
$width=$element[“width”];
回显“。\n”;
我的输出:

<iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=6" height="200" width="450" frameborder="0"> &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=7" height="200" width="450" frameborder="0"&gt; &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=11" height="200" width="450" frameborder="0"&gt; &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=4" height="200" width="350" frameborder="0"&gt; &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=8" height="200" width="450" frameborder="0"&gt; &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=10" height="200" width="450" frameborder="0"&gt; &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=3" height="200" width="450" frameborder="0"&gt; &lt;\iframe&gt;
&lt;iframe src="http://192.168.86.105:3000/dashboard-solo/db/home?panelId=5" height="200" width="350" frameborder="0"&gt; &lt;\iframe&gt;
</iframe>
\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=7“height=“200”width=“450”frameborder=“0”\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=11“height=“200”width=“450”frameborder=“0”\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=4“height=“200”width=“350”frameborder=“0”\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=8“height=“200”width=“450”frameborder=“0”\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=10“height=“200”width=“450”frameborder=“0”\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=3“height=“200”width=“450”frameborder=“0”\iframe
iframe src=”http://192.168.86.105:3000/dashboard-solo/db/home?panelId=5“height=“200”width=“350”frameborder=“0”\iframe

检查修改的foreach循环:

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";
} 
foreach($dl作为$element){
$url=$element[“url”];
$height=$element[“height”];
$width=$element[“width”];
回音“\n”;
} 

应该使用
/
作为
。这可能是问题所在。无论您使用什么来显示输出,似乎都是对后续数据行进行html编码,因为它将这些数据行放在第一个iFrame中,而不是创建新的数据行。显示这些数据行的代码是什么?显示所有代码。您提供的部分不是够了。你能把这个答案标记为已批准吗?完成了,抱歉耽搁了。