checkbox postback function return empty string
<p>I have a function which always echoes out an empty string when the page is posted back. What I'm trying to do is check if the name of the checkbox field is in the <code>$departments</code> array and if it is make it checked upon postback.</p>

<p>PHP:</p>

<pre><code>function isChecked($name) {
    $departments = (isset($_POST["interests"])) ? $_POST["interests"] : null;
    if(in_array($name, $departments)) {
        return "checked";
    }
    return "";
}
</code></pre>

<p>HTML</p>

<pre><code>&lt;input type="checkbox" id="computers" name="interests[]" 
&lt;?PHP echo isChecked('computers') ?&gt; /&gt;
</code></pre>

<p>I just realized I have used <code>interests[]</code> array declaration so how do I make it checked with indexes?</p>

<p>this is my var_dump:</p>

<pre><code>'interests' =&gt; 
array (size=3)
  0 =&gt; string 'Computers' (length=9)
  1 =&gt; string 'Appliances' (length=10)
  2 =&gt; string 'Beauty' (length=6)
</code></pre>
