title: Passing PHP array into Javascript through JSON to update Google Chart
body: <p>I have three PHP arrays that I've encoded with json... extra PHP code has been omitted because the arrays work properly.... Additionally, the HTML  tags that call the google chart have been omitted for sake of brevity... </p>
  
  <pre><code>&lt;?php
  $encoded_line_volume = json_encode($LineVol) . "\n";
  $encoded_loan_volume = json_encode($LoanVol) . "\n";
  $encoded_cluster_name = json_encode($ClusterLine) . "\n";
  ?&gt;
  </code></pre>
  
  <p>I would like to access these three arrays in Javascript to update my Google Chart dynamically.  </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  google.load("visualization", "1", {packages:["columnchart"]});
  google.setOnLoadCallback(drawChart);
  
  var linevol = new Array;  // This would be the first array passed from PHP
  var loanvol = new Array;  // This would be the second array passed from PHP
  var clusters = new Array; // This would be the third array passed from PHP
  
  function drawChart() {
      var data = new google.visualization.DataTable();
  
      data.addColumn('string', 'Cluster');
      data.addColumn('number', 'Loans');
      data.addColumn('number', 'Lines');
  
  /* create for loops to add as many columns as necessary */
  
  var len = jsonarray.length;
  
      data.addRows(len);
  
  for(i=0; i&lt;len; i++) {
  
  data.setValue(i, 0, ' '+clusters[i]+'');     /* x-axis */
  data.setValue(i, 1, linevol[i]);   /* Y-axis category #1*/
  data.setValue(i, 2, loanvol[i]);   /* Y-axis category #2*/
  }
  /*********************************end of loops***************************************/
    var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
    chart.draw(data, {width: 400, height: 240, is3D: true, title: 'Prospect Population', legend: 'right'});
  }
  &lt;/script&gt;
  </code></pre>