title: Iterating over a PHP array inside a Javascript loop
body: <p>I'm having some troubles trying to iterate over a PHP array inside a Javascript array... I've searched over the forum and, though I found some posts about copying PHP values to Javascript values, I'm unable to find exactly what I'm trying to achieve... </p>
  
  <p>I have a PHP array of arrays called "phpArray", and I want each value of this array to be copied into a Javascript array of arrays (called "javaArray"). I have a Javascript loop that populates the Javascript array when the "phpArray" comes empty, and I'm simply trying to use a PHP index to iterate over the "phpArray". However, it acts as if the PHP index is never increased, and the only array value that I can get is the first one of the "phpArray"... Here is the piece of code corresponding to this:</p>
  
  <pre><code>for (var i = 0; i &lt; javaArray.length; i++) {
      javaArray[i] = new Array(&lt;?php echo $numCols; ?&gt;);
  
      for (var j = 0; j &lt; javaArray[i].length; j++) {
          javaArray[i][j] = "0";
  
          &lt;?php 
          if(sizeof($javaArray) &gt; 0)
          {
              ?&gt;
              javaArray[i][j] = "&lt;?php echo $phpArray[$i][$j]; ?&gt;";
              &lt;?php
          }
          ?&gt;
      }
  }
  </code></pre>
  
  <p>Any idea on how can I do this?</p>
  
  <p>Thanks in advance for your time and effort! :)</p>