Looping a json encode filtered by type
<p>I create a json encode in PHP like this:</p>

<pre><code>$get = mysql_query("SELECT * FROM $table") or die(mysql_error());
$data = array();
        while($row = mysql_fetch_assoc($get)){
            $data[$row['id']][0] = $row['g'];
            $data[$row['id']][1] = $row['w'];
            $data[$row['id']][2] = $row['s'];
            $data[$row['id']][3] = $row['name'];
            $data[$row['id']][4] = $row['type'];
            }
$data4 = json_encode($data);        
</code></pre>

<p>I assign it to a js variable: var bdata;</p>

<p>So what im trying to do is now loop the content filtered by [4] = type.</p>

<p>This is my loop:</p>

<pre><code> for(var key in bdata){
 //stuff here
 }
</code></pre>

<p>But this will loop all of them... but I want to loop only ones that have a [4] (type) of a certain value lets say the value was "2".</p>

<p>Is there a way to do that?</p>
