You are here

function _googleanalytics_get_name_value_string in Google Analytics 6.4

Same name and namespace in other branches
  1. 7.2 googleanalytics.admin.inc \_googleanalytics_get_name_value_string()

Generates a string representation of an array.

This string format is suitable for edition in a textarea.

Parameters

array $values: An array of values, where array keys are values and array values are labels.

Return value

string The string representation of the $values array:

  • Values are separated by a carriage return.
  • Each value is in the format "name|value" or "value".
1 call to _googleanalytics_get_name_value_string()
googleanalytics_admin_settings_form in ./googleanalytics.admin.inc
Implementation of hook_admin_settings() for module settings configuration.

File

./googleanalytics.admin.inc, line 819
Administrative page callbacks for the googleanalytics module.

Code

function _googleanalytics_get_name_value_string($values) {
  $lines = array();
  foreach ($values as $name => $value) {

    // Convert data types.
    // @todo: #2251377: Json utility class serializes boolean values to incorrect data type
    if (is_bool($value)) {
      $value = $value ? 'true' : 'false';
    }
    $lines[] = "{$name}|{$value}";
  }
  return implode("\n", $lines);
}