Class ArrayUtil
Utility class for array manipulation.
Methods summary
public static
flatten( array $nestedArrays
)
: array
Flattens nested non-associative arrays, without preserving keys.
Flattens nested non-associative arrays, without preserving keys.
Return array()
if a non array argument has been given.
Parameters
$nestedArrays
- The nested arrays to flatten.
Returns
array
public static
getIfSet( array $array
, integer|string $key
, mixed $notSet
= null )
: mixed
Return a given array key if it isset
or a default value.
Return a given array key if it isset
or a default value.
Note: Using isset
implies that if the key is present according to array_key_exists()
but is associated to the value null
, the default value will be returned instead (which defaults to null
).
Parameters
$array
- The array to look into
$key
- The desired key
$notSet
- The default value to return if the key is missing or its associated value is
null
.
Returns
mixed
public static
is_not_null( mixed $var
)
: boolean
Utility function !is_null()
.
Utility function !is_null()
.
Parameters
Returns
boolean
See
public static
filterNulls( array $array
)
: array
Filter null values from an array.
Filter null values from an array.
This differs from array_filter($array)
without callback in that a strict comparison is used for null
,
so 0
, false
, ""
, array()
and the like will not be filtered out.
Parameters
Returns
array