em_core_helper.php
LimeSurvey Copyright (C) 2007-2026 The LimeSurvey Project Team All rights reserved.
License: GNU/GPL License v2 or later, see LICENSE.php LimeSurvey is free software. This version may have been modified pursuant to the GNU General Public License, and as distributed it includes or is derivative of works licensed under the GNU General Public License or other free or open source software licenses. See COPYRIGHT.php for copyright notices and details.
Table of Contents
Classes
- ExpressionManager
- Description of ExpressionManager (1) Does safe evaluation of PHP expressions. Only registered Functions, and known Variables are allowed.
Functions
- cmpErrorTokens() : int
- Used by usort() to order Error tokens by their position within the string This must be outside of the class in order to work in PHP 5.2
- cmpWarningTokens() : int
- exprmgr_count() : int
- Count the number of answered questions (non-empty)
- exprmgr_countif() : int
- Count the number of answered questions (non-empty) which match the first argument
- exprmgr_countifop() : int
- Count the number of answered questions (non-empty) which meet the criteria (argument - operator - value)
- exprmgr_stripos() : int|false
- Find position of first occurrence of unicode string in a unicode string, case insensitive
- exprmgr_stristr() : string|false
- Finds first occurrence of a unicode string within another, case-insensitive
- exprmgr_strlen() : int
- Get unicode string length
- exprmgr_strpos() : int|false
- Find position of first occurrence of unicode string in a unicode string
- exprmgr_strstr() : string|false
- Finds first occurrence of a unicode string within another
- exprmgr_strtolower() : string
- Make an unicode string lowercase
- exprmgr_strtoupper() : string
- Make an unicode string uppercase
- exprmgr_substr() : string
- Get part of unicode string
- exprmgr_sumifop() : int
- Sum values from a list that satisfy a comparison against a reference value.
- exprmgr_checkdate() : bool
- Determine whether the given month, day, and year form a valid Gregorian calendar date.
- exprmgr_convert_value() : int|null
- Find the closest matching Numerical input values in a list an replace it by the corresponding value within another list
- exprmgr_date() : string|false
- Return format a local time/date Need to test if timestamp is numeric (else E_WARNING with debug>0)
- exprmgr_abs() : mixed
- exprmgr_array_sum() : float
- Calculate the sum of values in an array
- exprmgr_if() : mixed
- If $test is true, return $iftrue, else return $iffalse
- exprmgr_int() : int
- Return true if the variable is an integer for LimeSurvey Allow usage of numeric answercode as int Can not use is_int due to SQL DECIMAL system.
- exprmgr_list() : string
- Join together $args[0-N] with ', '
- exprmgr_listifop() : string
- Implementation of listifop( $cmpAttr, $op, $value, $retAttr, $glue, $sgqa1, ..., sgqaN ) Return a list of retAttr from sgqa1...sgqaN which pass the criteria (cmpAttr op value)
- exprmgr_log() : float
- return log($arg[0],$arg[1]=e)
- exprmgr_mktime() : int|bool
- Get Unix timestamp for a date : false if parameters is invalid.
- exprmgr_join() : string
- Join together $args[N]
- exprmgr_implode() : string
- Join together $args[1-N] with $arg[0]
- exprmgr_empty() : bool
- Return true if the variable is NULL or blank.
- exprmgr_stddev() : float
- Compute the Sample Standard Deviation of a set of numbers ($args[0-N])
- expr_mgr_htmlspecialchars() : string
- Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES
- expr_mgr_htmlspecialchars_decode() : string
- Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES
- exprmgr_regexMatch() : bool
- Return true if $input matches the regular expression $pattern
- geterrors_exprmgr_regexMatch() : string|null
- Return error information from pattern of regular expression $pattern
- exprmgr_fixnum() : string
- Display number with comma as radix separator, if needed
- exprmgr_unique() : bool
- Returns true if all non-empty values are unique
Functions
cmpErrorTokens()
Used by usort() to order Error tokens by their position within the string This must be outside of the class in order to work in PHP 5.2
cmpErrorTokens(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>
Return values
intcmpWarningTokens()
cmpWarningTokens(EMWarningInterface $a, EMWarningInterface $b) : int
Parameters
- $a : EMWarningInterface
- $b : EMWarningInterface
Tags
Return values
intexprmgr_count()
Count the number of answered questions (non-empty)
exprmgr_count(array<string|int, mixed> $args) : int
Parameters
- $args : array<string|int, mixed>
Return values
intexprmgr_countif()
Count the number of answered questions (non-empty) which match the first argument
exprmgr_countif(array<string|int, mixed> $args) : int
Parameters
- $args : array<string|int, mixed>
Return values
intexprmgr_countifop()
Count the number of answered questions (non-empty) which meet the criteria (argument - operator - value)
exprmgr_countifop(array<string|int, mixed> $args) : int
Parameters
- $args : array<string|int, mixed>
Return values
intexprmgr_stripos()
Find position of first occurrence of unicode string in a unicode string, case insensitive
exprmgr_stripos(string $haystack, string $needle[, $offset = 0 ]) : int|false
Parameters
Return values
int|false —: position or false if not found
exprmgr_stristr()
Finds first occurrence of a unicode string within another, case-insensitive
exprmgr_stristr(string $haystack, string $needle[, bool $before_needle = false ]) : string|false
Parameters
- $haystack : string
-
: checked string
- $needle : string
-
: string to find
- $before_needle : bool = false
-
: portion to return
Return values
string|falseexprmgr_strlen()
Get unicode string length
exprmgr_strlen(string $string) : int
Parameters
- $string : string
Return values
intexprmgr_strpos()
Find position of first occurrence of unicode string in a unicode string
exprmgr_strpos(string $haystack, string $needle[, int $offset = 0 ]) : int|false
Parameters
- $haystack : string
-
: checked string
- $needle : string
-
: string to find
- $offset : int = 0
-
: offset
Return values
int|false —: position or false if not found
exprmgr_strstr()
Finds first occurrence of a unicode string within another
exprmgr_strstr(string $haystack, string $needle[, bool $before_needle = false ]) : string|false
Parameters
- $haystack : string
-
: checked string
- $needle : string
-
: string to find
- $before_needle : bool = false
-
: portion to return
Return values
string|falseexprmgr_strtolower()
Make an unicode string lowercase
exprmgr_strtolower(string $string) : string
Parameters
- $string : string
Return values
stringexprmgr_strtoupper()
Make an unicode string uppercase
exprmgr_strtoupper(string $string) : string
Parameters
- $string : string
Return values
stringexprmgr_substr()
Get part of unicode string
exprmgr_substr(string $string, int $start[, int $end = null ]) : string
Parameters
- $string : string
- $start : int
- $end : int = null
Return values
stringexprmgr_sumifop()
Sum values from a list that satisfy a comparison against a reference value.
exprmgr_sumifop(array<string|int, mixed> $args) : int
$args must contain: the comparison operator (e.g. '==','!=','>','<','>=','<=','eq','ne','gt','lt','ge','le','RX'), then the comparison value (or regex when operator is 'RX'), followed by one or more values to test and include in the sum.
For operator 'RX', values are tested with preg_match against the provided pattern; invalid regex patterns are ignored.
Parameters
- $args : array<string|int, mixed>
-
[operator, comparisonValue, value1, value2, ...]
Return values
int —The sum of values that match the comparison criteria.
exprmgr_checkdate()
Determine whether the given month, day, and year form a valid Gregorian calendar date.
exprmgr_checkdate(mixed $month, mixed $day, mixed $year) : bool
Accepts integers or numeric strings for each component; non-numeric inputs cause the function to return false.
Parameters
- $month : mixed
-
Month value (1-12) as an integer or numeric string.
- $day : mixed
-
Day value as an integer or numeric string.
- $year : mixed
-
Year value as an integer or numeric string.
Return values
bool —true if the three values form a valid Gregorian date, false otherwise.
exprmgr_convert_value()
Find the closest matching Numerical input values in a list an replace it by the corresponding value within another list
exprmgr_convert_value(float $fValueToReplace, int $iStrict, string $sTranslateFromList, string $sTranslateToList) : int|null
Parameters
- $fValueToReplace : float
- $iStrict : int
-
- 1 for exact matches only otherwise interpolation the closest value should be returned
- $sTranslateFromList : string
-
- comma separated list of numeric values to translate from
- $sTranslateToList : string
-
- comma separated list of numeric values to translate to
Tags
Return values
int|nullexprmgr_date()
Return format a local time/date Need to test if timestamp is numeric (else E_WARNING with debug>0)
exprmgr_date(string $format[, int $timestamp = null ]) : string|false
Parameters
- $format : string
- $timestamp : int = null
Tags
Return values
string|falseexprmgr_abs()
exprmgr_abs(mixed $num) : mixed
Parameters
- $num : mixed
exprmgr_array_sum()
Calculate the sum of values in an array
exprmgr_array_sum(array<string|int, mixed> $args) : float
Parameters
- $args : array<string|int, mixed>
Tags
Return values
floatexprmgr_if()
If $test is true, return $iftrue, else return $iffalse
exprmgr_if(mixed $testDone, mixed $iftrue[, mixed $iffalse = '' ]) : mixed
Parameters
- $testDone : mixed
- $iftrue : mixed
- $iffalse : mixed = ''
exprmgr_int()
Return true if the variable is an integer for LimeSurvey Allow usage of numeric answercode as int Can not use is_int due to SQL DECIMAL system.
exprmgr_int(string $arg) : int
Parameters
- $arg : string
Tags
Return values
intexprmgr_list()
Join together $args[0-N] with ', '
exprmgr_list(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Return values
stringexprmgr_listifop()
Implementation of listifop( $cmpAttr, $op, $value, $retAttr, $glue, $sgqa1, ..., sgqaN ) Return a list of retAttr from sgqa1...sgqaN which pass the criteria (cmpAttr op value)
exprmgr_listifop(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Return values
stringexprmgr_log()
return log($arg[0],$arg[1]=e)
exprmgr_log(array<string|int, mixed> $args) : float
Parameters
- $args : array<string|int, mixed>
Return values
floatexprmgr_mktime()
Get Unix timestamp for a date : false if parameters is invalid.
exprmgr_mktime([int $hour = null ][, int $minute = null ][, int $second = null ][, int $month = null ][, int $day = null ][, int $year = null ]) : int|bool
Get default value for unset (or null) value E_NOTICE if arguments are not numeric (debug>0), then test it before
Parameters
- $hour : int = null
- $minute : int = null
- $second : int = null
- $month : int = null
- $day : int = null
- $year : int = null
Return values
int|boolexprmgr_join()
Join together $args[N]
exprmgr_join(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Return values
stringexprmgr_implode()
Join together $args[1-N] with $arg[0]
exprmgr_implode(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Return values
stringexprmgr_empty()
Return true if the variable is NULL or blank.
exprmgr_empty(null|string|bool $arg) : bool
Parameters
- $arg : null|string|bool
Return values
boolexprmgr_stddev()
Compute the Sample Standard Deviation of a set of numbers ($args[0-N])
exprmgr_stddev(array<string|int, mixed> $args) : float
Parameters
- $args : array<string|int, mixed>
Return values
floatexpr_mgr_htmlspecialchars()
Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES
expr_mgr_htmlspecialchars(string $string) : string
Parameters
- $string : string
Return values
stringexpr_mgr_htmlspecialchars_decode()
Javascript equivalent does not cope well with ENT_QUOTES and related PHP constants, so set default to ENT_QUOTES
expr_mgr_htmlspecialchars_decode(string $string) : string
Parameters
- $string : string
Return values
stringexprmgr_regexMatch()
Return true if $input matches the regular expression $pattern
exprmgr_regexMatch(string $pattern, string $input) : bool
Parameters
- $pattern : string
- $input : string
Return values
boolgeterrors_exprmgr_regexMatch()
Return error information from pattern of regular expression $pattern
geterrors_exprmgr_regexMatch(string $pattern, string $input) : string|null
Parameters
- $pattern : string
- $input : string
Return values
string|nullexprmgr_fixnum()
Display number with comma as radix separator, if needed
exprmgr_fixnum(string $value) : string
Parameters
- $value : string
Return values
stringexprmgr_unique()
Returns true if all non-empty values are unique
exprmgr_unique(array<string|int, mixed> $args) : bool
Parameters
- $args : array<string|int, mixed>