How do I loop through this array and remove any empty values:
[28] => Array
(
[Ivory] =>
[White] =>
)
[29] => Array
I believe this will do what you're looking for:
foreach( $array as $key => $value ) {
if( is_array( $value ) ) {
foreach( $value as $key2 => $value2 ) {
if( empty( $value2 ) )
unset( $array[ $key ][ $key2 ] );
}
}
if( empty( $array[ $key ] ) )
unset( $array[ $key ] );
}
It will loop through your outer array, descend into any arrays it contains and remove keys whose values are empty. Then, once it's done that, it will remove any keys from the outer array whose subvalues were all empty, too.
Note that it wouldn't work for a generic array, just the one you've provided (two-dimensional).