title: Copy PHP array into javascript array
body: <p>I want to copy a PHP array into javascript array. The javascript is being used in the PHP file. It is echoed in the PHP code so when i tried to create a new array in javascripy and just assign the PHP array onto it, it was giving me an error.  Array to string conversion. Could some one help me with this.</p>
  
  <pre><code> mysql_select_db("cerebra", $con);
   $sql="select name from details order by download desc limit 20";
   if (!mysql_query($sql,$con))`enter code here`
    {
    die('Error: ' . mysql_error());
    }
   $query=mysql_query($sql,$con);
   $names=array();
   while($row=mysql_fetch_array($query))
     {
  $names[]=$row[0];
     }
  </code></pre>
  
  <p>Here $names is the array i want to use in javascript</p>
  
  <p>then i echo my javascript inside the php code itself..:</p>
  
  <pre><code>   function makeRequest() {
     var d = document.getElementsByName(\"d\")[0].value;
     var request = gapi.client.drive.files.list();
  var newnames = new Array();
      newnames=$names;
    request.execute(function(resp)
  
   {        
      for (i=0; i&lt;resp.items.length; i++) {
          var titulo = resp.items[i].title;
          var fechaUpd = resp.items[i].modifiedDate;
          var userUpd = resp.items[i].lastModifyingUserName;
          var userEmbed = resp.items[i].embedLink;
          var userAltLink = resp.items[i].alternateLink;
          var download = resp.items[i].webContentLink;
          var hold=\"Download\";
          var flag=0;
  
           &lt;!-- var fileInfo = document.createElement('li');
        &lt;!--  fileInfo.appendChild(document.createTextNode('TITLE: ' + titulo + ' - LAST MODIF: ' + fechaUpd + ' - BY: ' + userUpd +'  url:  ' + hold.link(download)));                
         &lt;!-- document.getElementById('content').appendChild(fileInfo);
          &lt;!--for (var i=0;i&lt;newnames.length;i++){
      &lt;!--    if(newnames[i].toString() == titulo){
          document.write(titulo + \"&amp;nbsp;\");
          document.write(hold.link(download) + \"&lt;br&gt;\");
          &lt;!--flag=1;
      &lt;!--    }
          &lt;!--}
          }
          &lt;!--if(flag!=1){
          &lt;!--document.write(\"not found!\");
          &lt;!--}
  });    
  }
  </code></pre>
  
  <p>Here in the javascript i am trying to convert the php array into javascript array but its not working</p>