[wp-hackers] Removing empty values from serialized array

Mike Schinkel mikeschinkel at newclarity.net
Thu Aug 5 19:22:17 UTC 2010

On Aug 5, 2010, at 2:14 PM, Andrew Nacin wrote:
> Checkboxes only send data if they are checked. The simplest way to handle
> this normally is to use empty() -- $checkbox_value = !empty(
> $_POST['checkbox_field'] );.

Shouldn't you be including an isset() too?

> If you ever need to remove keys with empty
> values from an array, simply pass the array through array_filter() without a
> callback.

Good tip.


More information about the wp-hackers mailing list