handle multilayer json array in javascript
<p>I have a simple array that I am trying to handle. It consists of two parts. A group of <code>vid_ids</code> and a single element called <code>page</code>. I was initially using a for loop to go through just the vid_id array but now since I added the <code>page</code> element I am not quite sure how to handle it. Anyone have any ideas</p>

<p><strong>PHP</strong></p>

<pre><code>$array=array();
$sql = 'SELECT * from video LIMIT 0,9';
$stmt = $conn-&gt;prepare($sql);
$result=$stmt-&gt;execute();
while($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC))
{
    $array[]=htmlspecialchars( $row['vid_id'], ENT_NOQUOTES, 'UTF-8' );
}
$data['vid_array']=$array;
$data['page']=1;
$out = json_encode($data);
print $out;
</code></pre>

<p><strong>Javascript</strong></p>

<pre><code>$.getJSON("load_live.php?t=" + (new Date()), function(json) {  
    for(vid_array.i=0; i &lt; json.length; vid_array.i++) {
        $('#element').append('&lt;div id="'+json.vid_array[i]+'"&gt;&lt;/div&gt;');
    }
    $('#element').append(json.page);
});
</code></pre>

<p><strong>Json Output</strong></p>

<blockquote>
  <p>{"vid_array":["3si7bxwk8ftpnvsw1gcf6giyxxch46sn","jch0dfepnu9hn0uw3m283g429mcj63q6","arh3xeklxjlztffxtybnucfnzosetgr8","6duy7xxj274w2cmhauth1tj933ck5i6z","9xx6pefa52s38ez77s5nbhz6jywbohc6","4eslxxl4etj5smhhr3wymc6pr8kys10c","4db1hp47be4auel633okbg6l884u0ef5","incwb9juxug8h986r9xt738ru4n0camd","vmsoqx03vppflh646b3au6jrlzt6mkej"],"page":1}</p>
</blockquote>
