Overview

Packages

  • Util

Classes

  • Horde_Array
  • Horde_Array_Sort_Helper
  • Horde_Domhtml
  • Horde_String
  • Horde_Util
  • Horde_Variables
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Array

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

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

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

Package: Util
Category: Horde
License: LGPL 2.1
Author: Michael Slusarz slusarz@horde.org
Author: Marko Djukic marko@oblo.com
Author: Jan Schneider jan@horde.org
Located at Horde/Array.php
Methods summary
public static array
# prepareAddressList( array $addr )

Prepare a list of addresses for storage. Namely, trims and lowercases all addresses and then sort.

Prepare a list of addresses for storage. Namely, trims and lowercases all addresses and then sort.

Parameters

$addr
The list of addresses.

Returns

array
The list of addresses, prepared for storage.
public static integer
# sortAddressList( string $a, string $b )

Function used by usort() to sort an address list.

Function used by usort() to sort an address list.

Parameters

$a
Address #1.
$b
Address #2.

Returns

integer
-1, 0, or 1.
public static
# arraySort( array & $array, string $key = null, integer $dir = 0, boolean $assoc = true )

Sorts an array on a specified key. If the key does not exist, defaults to the first key of the array.

Sorts an array on a specified key. If the key does not exist, defaults to the first key of the array.

Parameters

$array
$array The array to be sorted, passed by reference.
$key
<p>The key by which to sort. If not specified then the first key is used.</p>
$dir
<p>Sort direction: 0 = ascending (default) 1 = descending</p>
$assoc
Keep key value association?
public static boolean
# getArrayParts( string $field, string & $base, array & $keys )

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.

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.

Parameters

$field
The field name to be examined.
$base
$base Will be set to the base element.
$keys
$keys Will be set to the list of keys.

Returns

boolean
True on sucess, false on error.
public static mixed
# getElement( array & $array, array & $keys, array $value = null )

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.

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.

Parameters

$array
$array The array to be used.
$keys
$keys The key path to follow as an array.
$value
<p>If set the target element will have this value set to it.</p>

Returns

mixed
The final value of the key path.
public static array
# getRectangle( array $array, integer $row, integer $col, integer $height, integer $width )

Returns a rectangle of a two-dimensional array.

Returns a rectangle of a two-dimensional array.

Parameters

$array
The array to extract the rectangle from.
$row
The start row of the rectangle.
$col
The start column of the rectangle.
$height
The height of the rectangle.
$width
The width of the rectangle.

Returns

array
The extracted rectangle.
public static array
# valuesToKeys( array $array )

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')

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')

Parameters

$array
An array of values.

Returns

array
An array with keys the same as values.
public static array
# replaceRecursive( array $a1, array $a2 )

Backported array_replace_recursive().

Backported array_replace_recursive().

Parameters

$a1
The old array.
$a2
The new array.

Returns

array
The merged array.
API documentation generated by ApiGen