YANA 4 PHP Framework
Docs For Class Hashtable
«utility» Hashtable
This is a static utility class to implement certain operations on hashtables (associative arrays).
Example for usage of the $key parameter:
Array { ID1 => Array { ID2 => 'value' } }To get the string 'value' from the hashtable above use $key = 'ID1.ID2'
The wildcard '*' may be used to refer to the hashtable as a whole.
Located in /includes/class_hashtable.php
Utility | --Hashtable
Name | Type | Description |
---|---|---|
$input | array | input array |
$case | int|bool | CASE_UPPER or CASE_LOWER |
This is a recursive implementation of the PHP function array_change_key_case(). It takes the same arguments: an array $input to work on and an optional argument $case. The argument $case can be one of two constants: CASE_LOWER and CASE_UPPER, where CASE_LOWER is the default.
Name | Type | Description |
---|---|---|
&$hash | array | associative array |
$key | string | address |
Returns bool(false) if the element identified by $key can not be found in the given hashtable or it is NULL. Returns bool(true) otherwise.
Name | Type | Description |
---|---|---|
&$hash | array | associative array |
$key | string | address |
Finds the value identified by $key and returns it. If the value is not found NULL is returned.
Name | Type | Description |
---|---|---|
$A | array | base array |
$B | array | merge with this array |
This function is pretty much the same as the php function "array_merge_recursive" except for the way how duplicate keys are treated. Dupplicate keys get replaced in this implementation rather than being appended.
You may provide two or more arrays to merge.
Example with 2 arrays:
Result:array ( 0 => 'b', 'a' => 'a', 1 => 'c' )
Example with 4 arrays:
Recursive example:
$a1 = array ( 0 => 1, 1 => array( 0 => 1, 'a' => 'b' ) ); $b = array ( 1 => array( 0 => 'c', 1 => 2, ) ); 2 => 3,Compute this via: Result:
array ( 0 => 1, 1 => array( 0 => 'c', 1 => 2, 'a' => 'b' ), 2 => 3 )
Name | Type | Description |
---|---|---|
&$hash | array | associative array |
$key | string | address |
Unsets the element identified by $key in the hashtable. Returns bool(false) if the element does not exist or the key is invalid. Returns bool(true) otherwise.
Name | Type | Description |
---|---|---|
&$hash | array | associative array |
$key | string | address |
$value | mixed | some new value |
Sets the element identified by $key to $value. If the value does not exist it gets inserted. If a previous value existed the value gets updated.
This function returns bool(false) if $key = '*' and $value is not an array - which is: trying overwrite the complete hashtable with a non-array value. It returns bool(true) otherwise.
Name | Type | Description |
---|---|---|
&$hash | array | associative array |
$key | string | address |
&$value | mixed | some new value |
Sets the element identified by $key to $value by passing it's reference. If the value does not exist it gets inserted. If a previous value existed the value gets updated.
This function returns bool(false) if $key = '*' and $value is not an array - which is: trying overwrite the complete hashtable with a non-array value. It returns bool(true) otherwise.
Name | Type | Description |
---|---|---|
&$hash | array | associative array |
$key | string | address |
$type | string | data type |
Set the data type of the element identified by $key to $type.
Returns bool(false) if the element is NULL or does not exist, or the $type parameter is invalid. Returns bool(true) otherwise.
Inherited From Utility
Documentation generated on Sun, 11 Mar 2007 15:02:31 +0100 by phpDocumentor 1.3.1