title: PHP Recursively unset array keys if match
body: <p>I have the following array that I need to recursively loop through and remove any child arrays that have the key 'fields'. I have tried array filter but I am having trouble getting any of it to work.</p>
  
  <pre><code>$myarray = array(
      'Item' =&gt; array(
          'fields' =&gt; array('id', 'name'),
          'Part' =&gt; array(
              'fields' =&gt; array('part_number', 'part_name')
          )
      ),
      'Owner' =&gt; array(
          'fields' =&gt; array('id', 'name', 'active'),
          'Company' =&gt; array(
              'fields' =&gt; array('id', 'name',),
              'Locations' =&gt; array(
                  'fields' =&gt; array('id', 'name', 'address', 'zip'),
                  'State' =&gt; array(
                      'fields' =&gt; array('id', 'name')
                  )
              )
          )
      )    
  );
  </code></pre>
  
  <p>This is how I need it the result to look like:</p>
  
  <pre><code>$myarray = array(
      'Item' =&gt; array(
          'Part' =&gt; array(
          )
      ),
      'Owner' =&gt; array(
          'Company' =&gt; array(
              'Locations' =&gt; array(
                  'State' =&gt; array(
                  )
              )
          )
      )    
  );
  </code></pre>