include/utils/array_utils.php
Functions
array_search_insensitive(
\unknown_type $key, \unknown_type $haystack
)
:
void
Search an array for a given value ignorning case sensitivity
Name | Type | Description |
---|---|---|
$key | \unknown_type | |
$haystack | \unknown_type |
deepArrayDiff(
$array1, $array2, $allowEmpty
=
false
)
:
array
This function returns an array of all the key=>value pairs in $array1 that are wither not present, or different in $array2.
If a key exists in $array2 but not $array1, it will not be reported. Values which are arrays are traced further and reported only if thier is a difference in one or more of thier children.
Name | Type | Description |
---|---|---|
$array1 | ||
$array2 | ||
$allowEmpty |
Type | Description |
---|---|
array | containing the differences between the two arrays |
object_to_array_recursive(
$obj
)
:
array
This function will attempt to convert an object to an array.
Loops are not checked for so this function should be used with caution.
Name | Type | Description |
---|---|---|
$obj |
Type | Description |
---|---|
array | representation of $obj |
override_recursive_helper(
$key_names, $array_name, $value
)
:
void
Name | Type | Description |
---|---|---|
$key_names | ||
$array_name | ||
$value |
override_value_to_string(
$array_name, $value_name, $value
)
:
void
Name | Type | Description |
---|---|---|
$array_name | ||
$value_name | ||
$value |
override_value_to_string_recursive(
$key_names, $array_name, $value, $eval
=
false
)
:
void
Name | Type | Description |
---|---|---|
$key_names | ||
$array_name | ||
$value | ||
$eval |
override_value_to_string_recursive2(
$array_name, $value_name, $value, $save_empty
=
true
)
:
void
Name | Type | Description |
---|---|---|
$array_name | ||
$value_name | ||
$value | ||
$save_empty |
setDeepArrayValue(
\unknown_type $array, \unknown_type $key, $value
)
:
void
Recursivly set a value in an array, creating sub arrays as necessary
Name | Type | Description |
---|---|---|
$array | \unknown_type | |
$key | \unknown_type | |
$value |
\SugarArray
Wrapper around PHP's ArrayObject class that provides dot-notation recursive searching for multi-dimensional arrays
- Parent(s)
- \ArrayObject
Methods
_getRecursive(
$raw_config, $children, $default
)
:
void
Name | Type | Description |
---|---|---|
$raw_config | ||
$children | ||
$default |
get(
string $key, mixed $default
=
null
)
:
mixed
Return the value matching $key if exists, otherwise $default value
This method uses dot notation to look through multi-dimensional arrays
Name | Type | Description |
---|---|---|
$key | string | key to look up |
$default | mixed | value to return if $key does not exist |
Type | Description |
---|---|
mixed |
staticGet(
array $haystack, string $needle, mixed $default
=
null
)
:
mixed
Provided as a convinience method for fetching a value within an existing array without instantiating a SugarArray
NOTE: This should only used where refactoring an array into a SugarArray is unfeasible. This operation is more expensive than a direct SugarArray as each time it creates and throws away a new instance
Name | Type | Description |
---|---|---|
$haystack | array | haystack |
$needle | string | needle |
$default | mixed | default value to return |
Type | Description |
---|---|
mixed |