function _convert_csv_to_array

8.0.x _convert_csv_to_array($args)
6.x _convert_csv_to_array($args)
7.x _convert_csv_to_array($args)
4.x _convert_csv_to_array($args)
5.x _convert_csv_to_array($args)
master _convert_csv_to_array($args)

Convert a csv string, or an array of items which may contain csv strings, into an array of items.

@returns array A simple list of items (e.g. array('a','b','c')


$args: A simple csv string; e.g. 'a,b,c' or a simple list of items; e.g. array('a','b','c') or some combination; e.g. array('a,b','c') or array('a,','b,','c,')

6 calls to _convert_csv_to_array()
drush_role_add_perm in commands/core/
Add one or more permission(s) to the specified role.
drush_role_remove_perm in commands/core/
Remove permission(s) from the specified role.
pm_parse_arguments in commands/pm/
Sanitize user provided arguments to several pm commands.
UserList::getFromOptions in lib/Drush/User/UserList.php
UserList::getFromParameters in lib/Drush/User/UserList.php
Given a comma-separated list of inputs, return accounts for users that match by uid,name or email address.

... See full list


includes/, line 199
The drush API implementation and helpers.


function _convert_csv_to_array($args) {
  // Step 1: implode(',',$args) converts from, say, array('a,','b,','c,') to 'a,,b,,c,'
  // Step 2: explode(',', ...) converts to array('a','','b','','c','')
  // Step 3: array_filter(...) removes the empty items
  // Step 4: array_map(...) trims extra whitespace from each item
  // (handles csv strings with extra whitespace, e.g. 'a, b, c')
  return array_map('trim', array_filter(explode(',', is_array($args) ? implode(',', $args) : $args)));