0
I have a code in PHP that creates a json:
<?php
$array3 = array(array('0,1300', 'Thalita', 'Nicole'));
echo json_encode($array3);
?>
And I have another code that is in jQuery that forms a graph, with the following settings:
var d1 = [
[0, 1450], [1, 1300], [2, 1600], [3, 1900], [4, 2100], [5, 2500], [6, 2200], [7, 2000], [8, 1950], [9, 1900], [10, 2000], [11, 2120]
];
I need to do is take the return of the json I created with PHP and play in this variable D1 to form the graph correctly. And not forgetting that you have to return with two [[ ]] as the variable D1 above.
How do you want to process the PHP return? It would be through a method?
– g.carvalho97
I would like to take the return of PHP, can be for $.post, $.ajax and play the result and play in the variable jQuery. I need to form a variable equal to D1.
– Alisson Acioli
@Alissonacioli, the two arrays are different. One has two fields per array, the other 3 and not numerical. What graph are you using? Flot? Highcharts?
– Sergio
Just remembering that in the latest versions of PHP you can declare arrays in a very similar way to Javascript. The first array with names you created would be: $array3 = [['0,1300', 'Thalita', 'Nicole']]; Now to create the array you want: $array = [[0 => 1450, 1=>1300, 2=>1600, 3=>1900]]; // etc
– NewtonWagner