将php数组中的文本值插入到javascript函数中

时间:2022-01-29 01:34:40
while( $row = mysqli_fetch_array($exec) ) {
$data_back[] = $row['Agencyname'];
}
$text_values = implode(", ", $data_back);

 var hprogress = new RGraph.HProgress('cvs', 0,maxlen,[<?php echo $collection?>])
        .Set('key', ['<?php echo $text_values?>'])

Above php array echos labels/names on top of a horizontal graph.

上面的php数组回声标签/名称在水平图表上方。

I tried array method to get text values(which represents names above that graph) though I can see their names but their are not formatted correctly.

我尝试使用数组方法来获取文本值(表示该图上方的名称)虽然我可以看到它们的名称,但它们的格式不正确。

So I'm unable to convey which label represents their respective value within the graph. Thanks in advance mates.

所以我无法在图表中传达哪个标签代表它们各自的值。在此先感谢您的配偶。

1 个解决方案

#1


1  

you can use json_encode to properly encode php array. instead of:

你可以使用json_encode来正确编码php数组。代替:

['<?php echo $text_values?>']

use

使用

<?php echo json_encode($data_back); ?>

#1


1  

you can use json_encode to properly encode php array. instead of:

你可以使用json_encode来正确编码php数组。代替:

['<?php echo $text_values?>']

use

使用

<?php echo json_encode($data_back); ?>