how to compare same values in array in php?
<p>I am getting the values from database as an array</p>

<pre><code>&lt;?php
    foreach($this-&gt;getlist as $value){
        foreach($this-&gt;listOfdealers as $list){

?&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;input type="checkbox" name="list[]" value=&lt;?php echo $list-&gt;nList?&gt;
            &lt;?php if($value-&gt;nSubList==$list-&gt;nList){echo 'checked';  } ?&gt; /&gt;
        &lt;label for="list_32"&gt;&lt;?php echo $list-&gt;nList?&gt;
        &lt;/label&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;?php
        }
    }
?&gt;
</code></pre>

<p>I just want to compare two array values and display the checkbox checked when they are equal, but here there are displaying 16 checkbox instead of four,as I am using two for loops and I dont want that.</p>

<p>$this->getlist is an array that is returning from database</p>
