Given:

  1. the chart on js is http://jsfiddle.net/ ;
  2. array in php with the number of articles for the year monthly - $ montharr;

How to transfer array values ​​$ montharr ( php ) to data graph ( js )?

series: [{ name: 'Фішки', type: 'column', yAxis: 1, data: [15, 22, 20, 36, 55, 44, 48, 33, 61, 33, 44, 54], tooltip: { valueSuffix: ' шт' } 
  • echo "'" . implode(', ' $montharr) . "'"; - E_p
  • 3
    Do it normally without crutches by ajax request - Serge Esmanovich

1 answer 1

Json_encode is great for transferring data from PHP to JS

The simplest example is:

 <?php $data = [1,2,3,4]; $jsData = json_encode($data); ?> <script type="text/javascript"> var data = <?=$jsData?>; console.log(data); </script>