Inhaltsverzeichnis

infoVars()

array infoVars(string|array variableNames)

The function infoVars() returns technical information about a variable in the dataset. This function is particularly useful if you want to work with (custom) variable names when programming a questionnaire and need the corresponding item IDs.

Return Value

The function always returns an array that uses the given variable name(s) as keys and contains either an array with information or (if no variable was found under that name) null.

The contained arrays include the following information:

Example

The following PHP code determines the corresponding item IDs from a list of variables in order to display them in the question AB01. Here, all variables belong to the question AB01.

$question = 'AB01';
$vars = ['genAlpha', 'genGamma', 'genEpsilon'];
$items = [];
foreach (infoVars($vars) as $info) {
  if ($info['question'] == $question) {
    $items[] = $info['item'];
  }
}
question($question, $items);