You are here

function nodewords_unique_values in Nodewords: D6 Meta Tags 6.3

Same name and namespace in other branches
  1. 6 nodewords.module \nodewords_unique_values()
  2. 6.2 nodewords.module \nodewords_unique_values()
1 call to nodewords_unique_values()
nodewords_basic_keywords_prepare in nodewords_basic/includes/nodewords_basic.nodewords.tags.inc
Set the meta tag content.

File

./nodewords.module, line 855
Implement an version that other modules can use to add meta tags.

Code

function nodewords_unique_values($text, array $options = array()) {
  $lc_values = array();
  $unique_values = array();
  $options += array(
    'separator' => ',',
    'max_items' => -1,
  );
  if (empty($text)) {
    return '';
  }
  foreach (array_filter(array_map('trim', explode($options['separator'], $text))) as $item) {
    $lowercase = drupal_strtolower($item);
    if (!in_array($lowercase, $lc_values)) {
      $lc_values[] = $lowercase;
      $unique_values[] = $item;
    }
  }
  if ($options['max_items'] > 0) {
    $unique_values = array_slice($unique_values, 0, $options['max_items']);
  }
  return implode($options['separator'], $unique_values);
}