PHP array into Javascript Array <p>Afternoon all. The code below works perfectly, however, I need to pull each row of the php sql array out and into the script var. Any ideas on how to write a while loop that could do this? Thanks for any help</p> <pre><code> var enableDays = ["&lt;?php echo mysql_result($result, 0, 'date'); ?&gt;"]; enableDays.push("&lt;?php echo mysql_result($result, 1, 'date'); ?&gt;"); </code></pre> <p>Additional Code::</p> <pre><code>$rows = array(); while ($row = mysql_fetch_assoc($result)) { $rows[] = $row; } var enableDays = [&lt;?php echo json_encode($rows); ?&gt;]; console.log(enableDays[1]); </code></pre>