Class ArrayTools (namespace Nette)


Array tools library.


Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /ArrayTools.php (line 29)
Public Method Summary
ArrayTools
Static class - cannot be instantiated.
static mixed
get ($arr, mixed $key, [mixed $default = NULL])
Returns array item or $default if item is not set.
static & mixed
getRef (mixed &$arr, mixed $key)
Returns reference to array item or $default if item is not set.
static void
insertAfter (&$arr, mixed $key, $inserted)
Inserts new array after item specified by key.
static void
insertBefore (&$arr, mixed $key, $inserted)
Inserts new array before item specified by key.
static array
mergeTree (array $arr1, array $arr2)
Recursively appends elements of remaining keys from the second array to the first.
static int
searchKey (array $arr, mixed $key)
Searches the array for a given key and returns the offset if successful.

Method Details

line 35

__construct

public ArrayTools __construct ()

Static class - cannot be instantiated.

Output
ArrayTools  

line 50

get

public static mixed get ($arr, mixed $key, [mixed $default = NULL])

Returns array item or $default if item is not set.

Example: $val = ArrayTools::get($arr, 'i', 123);

Input
$arr array
mixed $key key
mixed $default default value
Output
mixed  

line 70

getRef

public static mixed & getRef (mixed &$arr, mixed $key)

Returns reference to array item or $default if item is not set.

Input
mixed &$arr array
mixed $key key
Output
& mixed  

line 139

insertAfter

public static void insertAfter (&$arr, mixed $key, $inserted)

Inserts new array after item specified by key.

Input
&$arr input array
mixed $key key
$inserted inserted array
Output
void  

line 124

insertBefore

public static void insertBefore (&$arr, mixed $key, $inserted)

Inserts new array before item specified by key.

Input
&$arr input array
mixed $key key
$inserted inserted array
Output
void  

line 90

mergeTree

public static array mergeTree (array $arr1, array $arr2)

Recursively appends elements of remaining keys from the second array to the first.

Input
array $arr1
array $arr2
Output
array  

line 109

searchKey

public static int searchKey (array $arr, mixed $key)

Searches the array for a given key and returns the offset if successful.

Input
array $arr input array
mixed $key key
Output
int offset if it is found, FALSE otherwise