You are here

function Utils::wf_crm_str2array in Webform CiviCRM Integration 8.5

Convert a | separated string into an array

Parameters

string $str: String representation of key => value select options

Return value

array of select options

Overrides UtilsInterface::wf_crm_str2array

File

src/Utils.php, line 597
Webform CiviCRM module's common utility functions.

Class

Utils

Namespace

Drupal\webform_civicrm

Code

function wf_crm_str2array($str) {
  $ret = [];
  if ($str) {
    foreach (explode("\n", trim($str)) as $row) {
      if ($row && $row[0] !== '<' && strpos($row, '|')) {
        list($k, $v) = explode('|', $row);
        $ret[trim($k)] = trim($v);
      }
    }
  }
  return $ret;
}