PHP Class Bolt\Helpers\Arr

Datei anzeigen Open project: bolt/bolt Class Usage Examples

Public Methods

Method Description
isAssociative ( array $array ) : boolean Returns whether the given item is an associative array.
isIndexed ( array $array ) : boolean Returns whether the given item is an indexed array - zero indexed and sequential.
isIndexedArray ( array $arr ) : boolean Use {@see isIndexed} or {@see isAssociative} instead.
makeValuePairs ( array $array, string $key, string $value ) : array Make a simple array consisting of key=>value pairs, that can be used in select-boxes in forms.
mergeRecursiveDistinct ( array &$array1, array &$array2 ) : array This is the same as {@see array_replace_recursive}.
replaceRecursive ( array $array1, array $array2 ) : array Replaces values from second array into first array recursively.

Method Details

isAssociative() public static method

Note: Empty arrays are not.
public static isAssociative ( array $array ) : boolean
$array array
return boolean

isIndexed() public static method

Note: Empty arrays are.
public static isIndexed ( array $array ) : boolean
$array array
return boolean

isIndexedArray() public static method

This is the same as isIndexed but it does not check if array is zero-indexed and has sequential keys.
Deprecation: since 3.3, to be removed in 4.0.
public static isIndexedArray ( array $arr ) : boolean
$arr array
return boolean True if indexed, false if associative

makeValuePairs() public static method

Make a simple array consisting of key=>value pairs, that can be used in select-boxes in forms.
public static makeValuePairs ( array $array, string $key, string $value ) : array
$array array
$key string
$value string
return array

mergeRecursiveDistinct() public static method

Use that instead or the smarter {@see \replaceRecursive}.
Deprecation: since 3.3, to be removed in 4.0.
public static mergeRecursiveDistinct ( array &$array1, array &$array2 ) : array
$array1 array
$array2 array
return array

replaceRecursive() public static method

This differs from {@see \array_replace_recursive} in a couple ways: - Lists (indexed arrays) from second array completely replace list in first array. - Null values from second array do not replace lists or associative arrays in first (they do still replace scalar values).
public static replaceRecursive ( array $array1, array $array2 ) : array
$array1 array
$array2 array
return array The combined array