You are here

function wf_crm_aval in Webform CiviCRM Integration 7.5

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

Return a value from nested arrays or objects.

Parameters

array|object $haystack: The array to search

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

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

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

Return value

mixed found value or default

102 calls to wf_crm_aval()
theme_static_contact_element in includes/contact_component.inc
Theme the wrapper for a static contact element Includes normal webform theme wrappers plus a tokeninput-style name field
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
webform_civicrm_update_7301 in ./webform_civicrm.install
Update case features.

... See full list

File

./webform_civicrm.module, line 633
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;
}