You are here

array_filter.inc in Feeds Tamper 6

Same filename and directory in other branches
  1. 7 plugins/array_filter.inc

File

plugins/array_filter.inc
View source
<?php

/**
 * @file
 * Filters out empty values from an array.
 */
$plugin = array(
  'form' => 'feeds_tamper_array_filter_form',
  'callback' => 'feeds_tamper_array_filter_callback',
  'name' => 'Filter empty items',
  'multi' => 'direct',
  'category' => 'List',
);
function feeds_tamper_array_filter_form($importer, $element_key, $settings) {
  $form = array();
  $form['help'] = array(
    '#type' => 'markup',
    '#value' => t('Filter out empty values from a list.'),
  );
  return $form;
}
function feeds_tamper_array_filter_callback($source, $item_key, $element_key, &$field, $settings) {
  if (is_array($field)) {
    $field = array_values(array_filter($field));
  }
}