title: Compare associative array keys and values for checkbox
body: <p>I have a web form with checkboxes for Event Spaces.</p>
  
  <p><a href="https://i.stack.imgur.com/orPQK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/orPQK.jpg" alt="checkboxes"></a></p>
  
  <p>The checkbox values are grabbed from one table in my database "facility_event_charges":</p>
  
  <p><a href="https://i.stack.imgur.com/wvFCa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wvFCa.jpg" alt="facility event charges"></a></p>
  
  <p>Let's say I check 5 and 6, "Audio Visual Equipment" and "Audio Visual Technician" and submit my form. </p>
  
  <p>This will save the id(s) to a separate table that I have for that "Event Space"
  Let's say my "Event Space" has an ID of 63. The lookup table now has two entries for my id since I checked 2 of the checkboxes:</p>
  
  <p><a href="https://i.stack.imgur.com/7djhk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7djhk.jpg" alt="lookup table"></a></p>
  
  <p>All is good and saved.
  Now, let's say I need to actually edit the charges associated with this space.</p>
  
  <p>When I click edit, my webform renders the form fields BUT the checkboxes are empty!! Why? Because it is grabbing the data from my "facility_event_charges" table. </p>
  
  <p>I need to compare this table data (array) with the data saved in my lookup table (array) to figure out which values are in common and render a check in those checkboxes.</p>
  
  <p>Desired result in my edit space webform would have those checked
  <a href="https://i.stack.imgur.com/KO6YH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KO6YH.jpg" alt="checked"></a></p>
  
  <p>My checkbox "charges" array:</p>
  
  <pre><code>array(6) { 
  [1]=&gt; string(9) "Officials" 
  [2]=&gt; string(6) "Ushers" 
  [3]=&gt; string(19) "Additional Staffing" 
  [4]=&gt; string(16) "Special Lighting" 
  [5]=&gt; string(22) "Audio Visual Equipment" 
  [6]=&gt; string(23) "Audio Visual Technician" 
  }
  </code></pre>
  
  <p>--
  I can also generate the charges in this:</p>
  
  <pre><code>array(6) { 
  [0]=&gt; array(1) { ["FacilityEventCharge"]=&gt; array(2) { ["id"]=&gt; string(1) "1" ["type"]=&gt; string(9) "Officials" } } 
  [1]=&gt; array(1) { ["FacilityEventCharge"]=&gt; array(2) { ["id"]=&gt; string(1) "2" ["type"]=&gt; string(6) "Ushers" } } 
  [2]=&gt; array(1) { ["FacilityEventCharge"]=&gt; array(2) { ["id"]=&gt; string(1) "3" ["type"]=&gt; string(19) "Additional Staffing" } } 
  [3]=&gt; array(1) { ["FacilityEventCharge"]=&gt; array(2) { ["id"]=&gt; string(1) "4" ["type"]=&gt; string(16) "Special Lighting" } } 
  [4]=&gt; array(1) { ["FacilityEventCharge"]=&gt; array(2) { ["id"]=&gt; string(1) "5" ["type"]=&gt; string(22) "Audio Visual Equipment" } } 
  [5]=&gt; array(1) { ["FacilityEventCharge"]=&gt; array(2) { ["id"]=&gt; string(1) "6" ["type"]=&gt; string(23) "Audio Visual Technician" } } } 
  </code></pre>
  
  <p>My lookup table array:</p>
  
  <pre><code>array(2) { 
  [0]=&gt; array(1) { ["EventCharge"]=&gt; array(1) { ["facility_event_charges_id"]=&gt; string(1) "5" } } 
  [1]=&gt; array(1) { ["EventCharge"]=&gt; array(1) { ["facility_event_charges_id"]=&gt; string(1) "6" } } 
  } 
  </code></pre>
  
  <p>--
  I've been unsuccessful in my attempts - tried php array_intersect
  array_intersect_assoc
  array_map('array_diff_assoc')</p>
  
  <p>I need to loop through the checkbox charges array and find a match from the lookup table array, when it matches, mark the checkbox "checked".</p>
  
  <p>Anyone have any working examples I could test out?
  The checkbox charges array <strong>key</strong> is what would need to match the <strong>"facility_event_charges_id"</strong></p>