是否可以使用.txt文件的数字值来填充php图上的值?
当前已设置图形,请参见下面的代码。我只需要弄清楚如何获取服务器上的txt文件填充的(值1),(值2),(值3)。
<?php
$dataPoints1 = array(
array(
"label" => "column1",
"y" => (value 1)
),
array(
"label" => "column2",
"y" => (value 2)
),
array(
"label" => "column3",
"y" => (value 3)
)
);
?>
答案 0 :(得分:0)
也许是这样,我没有测试,但是应该可以 $ myFile =“ file.txt”;
$json_data = json_decode(file_get_contents($myFile), true);
$value1 = $json_data['value1'];
$value2 = $json_data['value2'];
$value3 = $json_data['value3'];
$dataPoints1 = array(
array(
"label" => "column1",
"y" => $value1
),
array(
"label" => "column2",
"y" => $value2
),
array(
"label" => "column3",
"y" => $value3
)
);
file.txt:
{"value1":1,"value2":2,"value3":3}