Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

(no description)

File Size: 147 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Horde_Array:: (5 methods):
  arraySort()
  getArrayParts()
  getElement()
  getRectangle()
  valuesToKeys()


Class: Horde_Array  - X-Ref

The Horde_Array:: class provides various methods for array manipulation.

Copyright 2003-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you
did not receive this file, see http://www.horde.org/licenses/lgpl21.

arraySort(array &$array, $key = null, $dir = 0,$assoc = true)   X-Ref
Sorts an array on a specified key. If the key does not exist,
defaults to the first key of the array.

param: array &$array   The array to be sorted, passed by reference.
param: string $key     The key by which to sort. If not specified then
param: integer $dir    Sort direction:
param: boolean $assoc  Keep key value association?

getArrayParts($field, &$base, &$keys)   X-Ref
Given an HTML type array field "example[key1][key2][key3]" breaks up
the keys so that they could be used to reference a regular PHP array.

param: string $field  The field name to be examined.
param: string &$base  Will be set to the base element.
param: array &$keys   Will be set to the list of keys.
return: boolean  True on sucess, false on error.

getElement(&$array, array &$keys, $value = null)   X-Ref
Using an array of keys iterate through the array following the
keys to find the final key value. If a value is passed then set
that value.

param: array &$array  The array to be used.
param: array &$keys   The key path to follow as an array.
param: array $value   If set the target element will have this value set
return: mixed  The final value of the key path.

getRectangle(array $array, $row, $col, $height,$width)   X-Ref
Returns a rectangle of a two-dimensional array.

param: array   $array   The array to extract the rectangle from.
param: integer $row     The start row of the rectangle.
param: integer $col     The start column of the rectangle.
param: integer $height  The height of the rectangle.
param: integer $width   The width of the rectangle.
return: array  The extracted rectangle.

valuesToKeys(array $array)   X-Ref
Given an array, returns an associative array with each element key
derived from its value.
For example:
array(0 => 'foo', 1 => 'bar')
would become:
array('foo' => 'foo', 'bar' => 'bar')

param: array $array  An array of values.
return: array  An array with keys the same as values.