how to read json file into a php array and plot a graph by using this array?
i am able to read a json file into an array and display the output but i
want to use that array directly to give it as a input to another php
function to plot a graph,
how to read json file into a php array and plot a graph by using this array ?
<?php
$string = file_get_contents("json.json");
$example_data=json_decode($string,true);
foreach ($example_data as $k => $v) {
echo $k, ' : ', $v;
}
?>
but instead of displaying it as an output text, i want to give this
example_data as an input array to another php function,
<?php
//Include the code
require_once 'C:/xampp/htdocs/formattool/phplot-6.1.0/phplot.php';
//Define the object
$plot = new PHPlot();
//Define some data
$example_data = array(
array('a',3),
array('b',5),
array('c',7),
array('d',8),
array('e',2),
array('f',6),
array('g',7)
);
$plot->SetDataValues($example_data);
//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
?>
in the above code, instead of declaring the example_data, i want to read
it from another json file as i did in the first code, can anyone give me a
solution to this ?
No comments:
Post a Comment