Zend Framework
3.0
|
Utility class for testing and manipulation of PHP arrays. More...
Static Public Member Functions | |
static | hasStringKeys ($value, $allowEmpty=false) |
Test whether an array contains one or more string keys. | |
static | hasIntegerKeys ($value, $allowEmpty=false) |
Test whether an array contains one or more integer keys. | |
static | hasNumericKeys ($value, $allowEmpty=false) |
Test whether an array contains one or more numeric keys. | |
static | isList ($value, $allowEmpty=false) |
Test whether an array is a list. | |
static | isHashTable ($value, $allowEmpty=false) |
Test whether an array is a hash table. | |
static | inArray ($needle, array $haystack, $strict=false) |
Checks if a value exists in an array. | |
static | iteratorToArray ($iterator, $recursive=true) |
Convert an iterator to an array. | |
static | merge (array $a, array $b, $preserveNumericKeys=false) |
Merge two arrays together. | |
static | filter (array $data, $callback, $flag=null) |
Compatibility Method for array_filter on <5.6 systems. | |
Public Attributes | |
const | ARRAY_FILTER_USE_BOTH = 1 |
Compatibility Flag for ArrayUtils::filter. | |
const | ARRAY_FILTER_USE_KEY = 2 |
Compatibility Flag for ArrayUtils::filter. | |
Utility class for testing and manipulation of PHP arrays.
Declared abstract, as we have no need for instantiation.
|
static |
Compatibility Method for array_filter on <5.6 systems.
array | $data | |
callable | $callback | |
null | int | $flag |
|
static |
Test whether an array contains one or more integer keys.
mixed | $value | |
bool | $allowEmpty | Should an empty array() return true |
|
static |
Test whether an array contains one or more numeric keys.
A numeric key can be one of the following:
mixed | $value | |
bool | $allowEmpty | Should an empty array() return true |
|
static |
Test whether an array contains one or more string keys.
mixed | $value | |
bool | $allowEmpty | Should an empty array() return true |
|
static |
Checks if a value exists in an array.
Due to "foo" == 0 === TRUE with in_array when strict = false, an option has been added to prevent this. When $strict = 0/false, the most secure non-strict check is implemented. if $strict = -1, the default in_array non-strict behaviour is used.
mixed | $needle | |
array | $haystack | |
int | bool | $strict |
|
static |
Test whether an array is a hash table.
An array is a hash table if:
1. Contains one or more non-integer keys, or 2. Integer keys are non-continuous or misaligned (not starting with 0)
For example: $hash = array( 'foo' => 15, 'bar' => false, ); $hash = array( 1995 => 'Birth of PHP', 2009 => 'PHP 5.3.0', 2012 => 'PHP 5.4.0', ); $hash = array( 'formElement, 'options' => array( 'debug' => true ), );
mixed | $value | |
bool | $allowEmpty | Is an empty array() a valid hash table? |
|
static |
Test whether an array is a list.
A list is a collection of values assigned to continuous integer keys starting at 0 and ending at count() - 1.
For example: $list = array('a', 'b', 'c', 'd'); $list = array( 0 => 'foo', 1 => 'bar', 2 => array('foo' => 'baz'), );
mixed | $value | |
bool | $allowEmpty | Is an empty list a valid list? |
|
static |
Convert an iterator to an array.
Converts an iterator to an array. The $recursive flag, on by default, hints whether or not you want to do so recursively.
array | Traversable | $iterator | The array or Traversable object to convert |
bool | $recursive | Recursively check all nested structures |
Exception\InvalidArgumentException | if $iterator is not an array or a Traversable object |
|
static |
Merge two arrays together.
If an integer key exists in both arrays and preserveNumericKeys is false, the value from the second array will be appended to the first array. If both values are arrays, they are merged together, else the value of the second array overwrites the one of the first array.
array | $a | |
array | $b | |
bool | $preserveNumericKeys |
const ARRAY_FILTER_USE_BOTH = 1 |
Compatibility Flag for ArrayUtils::filter.
const ARRAY_FILTER_USE_KEY = 2 |
Compatibility Flag for ArrayUtils::filter.