Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

utility functions PHP versions 4 and 5

Author: Chuck Burgess <ashnazg@php.net>
Copyright: 2001-2018 The PHP Group
License: http://www.php.net/license/3_01.txt PHP License 3.01
Version: CVS: $Id$
File Size: 159 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

HTML_QuickForm_utils:: (6 methods):
  pathGet()
  pathIsset()
  pathSet()
  recursiveIsset()
  recursiveValue()
  recursiveBuild()


Class: HTML_QuickForm_utils  - X-Ref

Provides a collection of static methods for array manipulation.

(courtesy of CiviCRM project (https://civicrm.org/)

pathGet($values, $path, $default = NULL)   X-Ref
Get a single value from an array-tree.

param: array     $values   Ex: ['foo' => ['bar' => 123]].
param: array     $path     Ex: ['foo', 'bar'].
param: mixed     $default
return: mixed               Ex 123.

pathIsset($values, $path)   X-Ref
Check if a key isset which may be several layers deep.

This is a helper for when the calling function does not know how many layers deep
the path array is so cannot easily check.

param: array $values
param: array $path
return: bool

pathSet(&$values, $pathParts, $value)   X-Ref
Set a single value in an array tree.

param: array   $values     Ex: ['foo' => ['bar' => 123]].
param: array   $pathParts  Ex: ['foo', 'bar'].
param: mixed   $value      Ex: 456.
return: void

recursiveIsset($array, $path)   X-Ref
Check if a key isset which may be several layers deep.

This is a helper for when the calling function does not know how many layers deep the
path array is so cannot easily check.

param: array $array
param: array $path
return: bool

recursiveValue($array, $path, $default = NULL)   X-Ref
Check if a key isset which may be several layers deep.

This is a helper for when the calling function does not know how many layers deep the
path array is so cannot easily check.

param: array   $array
param: array   $path       An array of keys,
param: mixed   $default    Value to return if not found.
return: bool

recursiveBuild($path, $value, $source = array()   X-Ref
Append the value to the array using the key provided.

e.g if value is 'llama' & path is [0, 'email', 'location'] result will be
[0 => ['email' => ['location' => 'llama']]

param: $path
param: $value
param: array   $source
return: array