Title: Do something when nothing is in the array
Last modified: August 22, 2016

---

# Do something when nothing is in the array

 *  Resolved [Nathan Hawkes](https://wordpress.org/support/users/natehawkes/)
 * (@natehawkes)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/do-something-when-nothing-is-in-the-array/)
 * I have just downloaded Simple Fields and I think it’s fantastic. Just one query:
 * I am creating a custom events page and have an option to add event sponsors (
   fields provided by SF). Is it possible to have the sponsors section disappear
   if there are no meta options? Here is my code now:
 *     ```
       <?php
                     $event_sponsors = simple_fields_values( 'wca_events_sponsors_logo, wca_events_sponsors_name' );
                     if ( empty( $event_sponsors ) ) { ?>
                   <ul id="event-sponsors-list" class="event-list">
                     <?php foreach( $event_sponsors as $event_sponsor ) { ?>
                     <li style="background-image: url('<?php echo $event_sponsor['wca_events_sponsors_logo']['url']; ?>');" title="<?php echo $event_sponsor['wca_events_sponsors_name']; ?>">
                     </li>
                     <?php } ?>
                   </ul>
                   <?php } ?>
       ```
   
 * A `var_dump` of `$event_sponsors` gives:
 * `array(0) { }`
 * so in theory, `empty()` should work. Right? Is there something I’ve missed?
 * [https://wordpress.org/plugins/simple-fields/](https://wordpress.org/plugins/simple-fields/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Nathan Hawkes](https://wordpress.org/support/users/natehawkes/)
 * (@natehawkes)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/do-something-when-nothing-is-in-the-array/#post-5893587)
 * Sorry, that would be my mistake. It’s late here in the UK -_-“
 * I should have had `!empty( $event_sponsors )`, not `empty( $event_sponsors )`.

Viewing 1 replies (of 1 total)

The topic ‘Do something when nothing is in the array’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simple-fields_fafafa.svg)
 * [Simple Fields](https://wordpress.org/plugins/simple-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-fields/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Nathan Hawkes](https://wordpress.org/support/users/natehawkes/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/do-something-when-nothing-is-in-the-array/#post-5893587)
 * Status: resolved