title: php array to javascript objects
body: <p>hi there im having a problem adding values to my graph from php array to javascript object so far i have a php values in the array</p>
  
  <pre><code>$data=array(5,10,15,20);
  </code></pre>
  
  <p>and i converted it to json to prepare for javascript</p>
  
  <pre><code>$js_array = json_encode($data);
  </code></pre>
  
  <p>and heres the javascipt part</p>
  
  <p>data : <code>&lt;?php echo json_encode( $data );  ?&gt;</code> </p>
  
  <p>i think it is reading it as </p>
  
  <pre><code>data : [5] or data : [5101520]
  </code></pre>
  
  <p>it was suppose to read it as</p>
  
  <pre><code>data : [5,10,15,20]
  </code></pre>
  
  <p>thanks guys hoping you can help me</p>
  
  <p>here is the php array storing</p>
  
  <pre><code>&lt;?php  
  $data = array();
  
  $que = "SELECT name FROM table1 ORDER BY date ASC";
  
  $res = mysql_query($que, $con);
  
  if(mysql_num_rows($res)&gt;0){
  
  while($row = mysql_fetch_array($res)){
  
  $data[] = $row['name'];
  
  }}
  
  $js_array = json_encode($data);
  
  ?&gt;'
  </code></pre>
  
  <p>here is the var dump data echo
      array(4) { [0]=> string(1) "5" <a href="https://i.stack.imgur.com/1ngEh.jpg" rel="nofollow noreferrer">1</a>=> string(2) "10" [2]=> string(2) "20" [3]=> string(2) "15" }</p>
  
  <p><img src="https://i.stack.imgur.com/1ngEh.jpg" alt="here is the current output"></p>