You are here

function imagefield_extended_keyed_values in ImageField Extended 6.3

Same name and namespace in other branches
  1. 6.4 imagefield_extended.module \imagefield_extended_keyed_values()

To parse a newline selection list into options.

1 call to imagefield_extended_keyed_values()
_imagefield_extended_fields in ./imagefield_extended.module
A private helper function to cache / normalise the custom field titles.

File

./imagefield_extended.module, line 313
Insert additional fields into an ImageField data array.

Code

function imagefield_extended_keyed_values($text, $required = FALSE) {
  $options = $required ? array(
    '' => '--',
  ) : array();
  $rows = array_filter(explode("\n", $text));
  $group = NULL;
  foreach ($rows as $option) {
    if (preg_match('/^([^|]+)\\|(.*)$/', $option, $matches)) {
      $options[$matches[1]] = $matches[2];
    }
  }
  return $options;
}