foreach for JSON array , syntax
<p>my script is getting some array from php server side script.</p>

<pre><code>result = jQuery.parseJSON(result);
</code></pre>

<p>now I want to check each variable of the array.</p>

<pre><code>if (result.a!='') { something.... }
if (result.b!='') { something.... }
....
</code></pre>

<p>Is there any better way to make it quick like in php 'foreach' , 'while' or smth ?</p>

<p><strong>UPDATE</strong></p>

<p>This code ( thanks to hvgotcodes ) gives me values of variables inside the array but how can I get the names of variables also ?</p>

<pre><code>for(var k in result) {
   alert(result[k]);
}
</code></pre>

<p><strong>UPDATE 2</strong></p>

<p>This is how php side works</p>

<pre><code>$json = json_encode(array("a" =&gt; "test", "b" =&gt; "test",  "c" =&gt; "test", "d" =&gt; "test"));
</code></pre>
