You are here

function _gmap_style_bubbles_validate_for_json in GMap Module 7.2

A helper function that breaks a string up into an array based on line breaks.

Anything before the first colon in each line is considered an array key, and anything following the first colon is that key's value.

An example string would be: Color : #cccccc minWidth: '250',

This function would output the following: array ( "Color" => "#cccccc", "minWidth" => "250" )

Trims whitespace, single and double quotes, semicolons and commas.

Related topics

1 call to _gmap_style_bubbles_validate_for_json()
gmap_style_bubbles_gmap in gmap_style_bubbles/gmap_style_bubbles.module
Enables hook_gmap().

File

gmap_style_bubbles/gmap_style_bubbles.module, line 117
Adds the more options for theming the gmap popup bubble.

Code

function _gmap_style_bubbles_validate_for_json($string) {
  $string_lines = explode("\n", $string);
  $clean_lines = array();
  foreach ($string_lines as $setting) {
    $this_line = explode(':', $setting, 2);
    if (isset($this_line[1])) {
      $clean_lines[trim($this_line[0])] = trim($this_line[1], "'\",; \r\n\t");
    }
  }
  return $clean_lines;
}