You are here

function wf_crm_aval in Webform CiviCRM Integration 7.3

Same name and namespace in other branches
  1. 8.5 webform_civicrm.module \wf_crm_aval()
  2. 7.5 webform_civicrm.module \wf_crm_aval()
  3. 7.4 webform_civicrm.module \wf_crm_aval()

Return a value from nested arrays or objects.

@return: found value or default

Parameters

$haystack: The array to search

$keys: Pass a single key, or multiple keys separated by : to get a nested value

$default: Value to return if given array key does not exist

$strict: Should we use empty or isset to determine if array key exists?

39 calls to wf_crm_aval()
theme_static_contact_element in ./contact_component.inc
Theme the wrapper for a static contact element Includes normal webform theme wrappers plus a tokeninput-style name field
theme_webform_civicrm_components_form in ./webform_civicrm_admin.inc
Theme override for webform components form.
webform_civicrm_update_6204 in ./webform_civicrm.install
Group participant options into a single array.
webform_civicrm_update_6205 in ./webform_civicrm.install
Upgrade for CiviCRM 4.1 compatibility.
webform_civicrm_update_7300 in ./webform_civicrm.install
Note: There are differences in how contact references and relationships work in the 3.x branch. Read the upgrade instructions at http://drupal.org/node/1615380

... See full list

File

./webform_civicrm.module, line 421
Webform CiviCRM Integration Module: Links webform submissions to contacts in a CiviCRM database. @author Coleman Watts

Code

function wf_crm_aval($haystack, $keys, $default = NULL, $strict = FALSE) {
  foreach (explode(':', $keys) as $key) {
    if (is_object($haystack)) {
      $haystack = (array) $haystack;
    }
    if (!is_array($haystack) || !isset($haystack[$key]) || empty($haystack[$key]) && $default !== NULL && !$strict) {
      return $default;
    }
    $haystack = $haystack[$key];
  }

  // $haystack has been reduced down to the item we want
  return $haystack;
}