Javascript post to PHP and get back an array?
<p>So i have this piece of javascript, it posts to <code>foo.php</code> with value <code>val</code>, gets back <code>data</code>, empties the container and call function <code>graph</code> which will fill the container with a new chart.</p>

<pre><code>$.post("foo.php", {val: val}, function(data){
    if(data.length &gt;0) {
        $('#container').html('');
        graph(data);
    } 
});
</code></pre>

<p>in <code>foo.php</code>, how do I make it pass back an array instead of string? at the moment I just have an <code>echo</code> in <code>foo.php</code> that echos the data delimited by a comma, ie: <code>1,2,3,4,5</code>. then in the <code>graph</code> function I have a <code>split(',' data)</code>  that creates an array for later use.</p>

<p>I mean, all this works fine, I'm just wondering if I can avoid the split step and have <code>foo.php</code> return an array directly.</p>

<p>thanks!</p>
