You are here

function webform_structured_text_parse_value in Webform Structured Text 7

Same name and namespace in other branches
  1. 6 structured_text.inc \webform_structured_text_parse_value()

Helper function to take a string value and parse it into an array based on a mask.

Parameters

mixed $mask Either the string mask, or the mask array.:

string $value The string value to be parsed.:

Return value

array The string $value broken into parts in an array, indexed by the part location.

2 calls to webform_structured_text_parse_value()
webform_structured_text_format_value in ./structured_text.inc
Helper function to format a value per a mask.
_webform_render_structured_text in ./structured_text.inc
Implements _webform_render_component().

File

./structured_text.inc, line 868

Code

function webform_structured_text_parse_value($mask, $value) {
  $mask_array = is_array($mask) ? $mask : webform_structured_text_parse_mask($mask);
  $value_array = array();
  $start = 0;
  foreach ($mask_array as $part => $details) {
    if ($details['type'] != 'markup') {
      $value_array[$part] = str_replace(WFST_PAD_CHARACTER, '', drupal_substr($value, $start, $details['length']));
      $start += $details['length'];
    }
  }
  return $value_array;
}