How do I assign a PHP array to a JS array?
<p>Below is my code where  the <strong>php array $keys</strong> assigned to a <strong>JS array var keysArr</strong>,
But the value display on the alert box is not correct.</p>

<p>Thus, there is something wrong on assign Php array to Js array.</p>

<p>Can anyone help me? Thanks in advance!</p>

<pre><code>&lt;?php
$keys = array(1, 2, 3, 4);
?&gt;
&lt;html&gt;
    &lt;head&gt;
    &lt;script type="text/javascript"&gt;
        var keysArr = &lt;?php print $keys?&gt;;
        for (var i = 0; i &lt; keysArr.length; ++i){

                    alert(keysArr[i]);

        }
    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
