title: Wordpress Widget Multiple Checkboxes with checked() Function
body: <p>I have a widget where multiple checkboxes can be selected in the backend. Currently I have the following code in my form function of the widget.</p>
  
  <pre><code>&lt;label for="&lt;?php echo $this-&gt;get_field_id("types"); ?&gt;"&gt;Types&lt;/label&gt;
          &lt;?php foreach ($types as $key =&gt; $val) : ?&gt;
              &lt;p&gt;
                  &lt;input class="checkbox" id="&lt;?php echo $this-&gt;get_field_id("types") . $key; ?&gt;" name="&lt;?php echo $this-&gt;get_field_name("types"); ?&gt;[]" type="checkbox" value="&lt;?php echo $key; ?&gt;" &lt;?php checked("1", array_key_exists($key, $instance["types"])); ?&gt; /&gt;
                  &lt;label for="&lt;?php echo $this-&gt;get_field_id("types") . $key; ?&gt;"&gt;&lt;?php echo $val; ?&gt;&lt;/label&gt;
              &lt;/p&gt;
          &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>The values are saved correctly but checked values are not displayed in return. Can Someone help me with this. I'm not sure how checked() function should be used in this context</p>
  
  <p>Thank You.</p>