Convert PHP array to JAVASCRIPT array
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2109531/generating-a-javascript-array-from-a-php-array">Generating a JavaScript array from a PHP array</a>  </p>
</blockquote>



<p>I just want to know how to create JavaScript array with the help of PHP and help are definitely appreciated </p>

<p>I have a PHP result to this form</p>

<pre><code>Array
(
    [0] =&gt; stdClass Object
        (
            [id] =&gt; 11
            [name] =&gt; MLB
            [totalcount] =&gt; 4
        )

    [1] =&gt; stdClass Object
        (
            [id] =&gt; 35
            [name] =&gt; American Idol
            [totalcount] =&gt; 2
        )

) 
</code></pre>

<p>and i want to convert this array to JavaScript array like this</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var myData = new Array(['MLB', 4], ['American Idol', 2]);
&lt;/script&gt;
</code></pre>
