title: How To Pass Values of Associated Array to Check-boxes
body: <p>Following snippet is generating 3 checkboxes with correct state from comparing two arrays but the outpt dosent render any value for lables like </p>
  
  <p><a href="https://i.stack.imgur.com/JCtHU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JCtHU.png" alt="enter image description here"></a></p>
  
  <p>but I need to display the value of <code>$items</code> for the inputs like</p>
  
  <p><a href="https://i.stack.imgur.com/AEBJg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AEBJg.png" alt="enter image description here"></a></p>
  
  <p>can you please let me know how modify the code to achieve this?</p>
  
  <pre><code>&lt;?php
  $items = ['2' =&gt; 'Full', '4' =&gt; 'No', '3' =&gt; 'Semi'];
  $selected = [2, 3];
  
  $keys = array_keys($items);
  foreach($keys as $key ){
      if (in_array($key, $selected)) {
           echo '&lt;input id="checkBox" value="'.$key.'" type="checkbox" checked&gt;';
      }
      else{
           echo '&lt;input id="checkBox" value="'.$key.'" type="checkbox"&gt;';
      }
  }
  
  ?&gt;
  </code></pre>