function drush_export_info

8.0.x drush.inc drush_export_info($info, $integer_keys = FALSE, $parents = array())
6.x drush.inc drush_export_info($info, $integer_keys = FALSE, $parents = array())
7.x drush.inc drush_export_info($info, $integer_keys = FALSE, $parents = array())
4.x drush.inc drush_export_info($info, $integer_keys = FALSE, $parents = array())
5.x drush.inc drush_export_info($info, $integer_keys = FALSE, $parents = array())
master drush.inc drush_export_info($info, $integer_keys = FALSE, $parents = array())

Generate code friendly to the Drupal .info format from a structured array. Mostly copied from http://drupalcode.org/viewvc/drupal/contributions/modules/features/featu....

Parameters

$info: An array or single value to put in a module's .info file.

boolean $integer_keys: Use integer in keys.

$parents: Array of parent keys (internal use only).

Return value

A code string ready to be written to a module's .info file.

File

includes/drush.inc, line 167
The drush API implementation and helpers.

Code

function drush_export_info($info, $integer_keys = FALSE, $parents = array()) {
  $output = '';
  if (is_array($info)) {
    foreach ($info as $k => $v) {
      $child = $parents;
      $child[] = $k;
      $output .= drush_export_info($v, $integer_keys, $child);
    }
  }
  else if (!empty($info) && count($parents)) {
    $line = array_shift($parents);
    foreach ($parents as $key) {
      $line .= (!$integer_keys && is_numeric($key)) ? "[]" : "[{$key}]";
    }
    $line .= " = \"{$info}\"\n";
    return $line;
  }
  return $output;
}