title: How to pass php array value to javascript variable
body: <p>I have working on core php, i have getting all values from database(select query) in this i have to executed while loop and changed to array variable after i have to pass that array value to javascript variable how to pass this please help.</p>
  
  <p>here my code:</p>
  
  <pre><code>&lt;?php
  include "db_connection.php";
  $locations=array();
      $query =  $conn-&gt;query('SELECT `pg_address` FROM `tbl_master_property` limit 10');
       while ($row =$query-&gt;fetch_assoc()) {
         $list[] = $row;
      }
      $locations=$list;
      //echo "&lt;pre&gt;";print_r($locations);die;
      //echo "&lt;pre&gt;";print_r($cart_info_json);die;
  
  ?&gt;  
  
  &lt;script type="text/javascript"&gt;
  var geocoder;
  var map;
  var data = &lt;?php echo json_encode($locations); ?&gt;; 
  //console.log(data);
  alert(data);
  </code></pre>
  
  <p>in this alert is showing (object,object,object,object,object,object,object,object)</p>