Automattic\WooCommerce\Blocks\Utils

ProductCollectionUtils::remove_empty_array_recursive()private staticWC 1.0

Remove falsy item from array, recursively.

Method of the class: ProductCollectionUtils{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = ProductCollectionUtils::remove_empty_array_recursive( $array );
$array(array) (required)
The input array to filter.

ProductCollectionUtils::remove_empty_array_recursive() code WC 8.9.0

private static function remove_empty_array_recursive( $array ) {
	$array = array_filter( $array );
	foreach ( $array as $key => $item ) {
		if ( is_array( $item ) ) {
			$array[ $key ] = self::remove_empty_array_recursive( $item );
		}
	}
	return $array;
}