Multidimensional array safe unique test
static array
arrayUnique
(array $myArray)
-
array
$myArray: The array to make unique.
Utility function to map an object to an array
static array
fromObject
(object $p_obj, [boolean $recurse = true], [string $regex = null])
-
object
$p_obj: The source object
-
boolean
$recurse: True to recurse through multi-level objects
-
string
$regex: An optional regular expression to match on field names
Extracts a column from an array of arrays or objects
static array
getColumn
(array &$array, string $index)
-
array
&$array: The source array
-
string
$index: The index of the column or name of object property
Utility function to return a value from a named array or a specified default
static mixed
getValue
(array &$array, string $name, [mixed $default = null], [string $type = ''])
-
array
&$array: A named array
-
string
$name: The key to search for
-
mixed
$default: The default value to give if no key found
-
string
$type: Return type for the variable (INT, FLOAT, STRING, WORD, BOOLEAN, ARRAY)
Takes an associative array of arrays and inverts the array keys to values using the array values as keys.
Example: $input = array( 'New' => array('1000', '1500', '1750'), 'Used' => array('3000', '4000', '5000', '6000') ); $output = JArrayHelper::invert($input);
Output would be equal to: $output = array( '1000' => 'New', '1500' => 'New', '1750' => 'New', '3000' => 'Used', '4000' => 'Used', '5000' => 'Used', '6000' => 'Used' );
static array
invert
(array $array)
-
array
$array: The source array.
Method to determine if an array is an associative array.
static boolean
isAssociative
(array $array)
-
array
$array: An array to test.
Pivots an array to create a reverse lookup of an array of scalars, arrays or objects.
static array
pivot
(array $source, [string $key = null])
-
array
$source: The source array.
-
string
$key: Where the elements of the source array are objects or arrays, the key to pivot on.
Utility function to sort an array of objects on a given field
static array
sortObjects
(array &$a, mixed $k, [mixed $direction = 1], [mixed $caseSensitive = true], [mixed $locale = false])
-
array
&$a: An array of objects
-
mixed
$k: The key (string) or a array of key to sort on
-
mixed
$direction: Direction (integer) or an array of direction to sort in [1 = Ascending] [-1 = Descending]
-
mixed
$caseSensitive: Boolean or array of booleans to let sort occur case sensitive or insensitive
-
mixed
$locale: Boolean or array of booleans to let sort occur using the locale language or not
Function to convert array to integer values
static void
toInteger
(array &$array, [mixed $default = null])
-
array
&$array: The source array to convert
-
mixed
$default: A default value (int|array) to assign if $array is not an array
Utility function to map an array to a stdClass object.
static object The
toObject
(array &$array, [string $class = 'stdClass'])
-
array
&$array: The array to map.
-
string
$class: Name of the class to create
Utility function to map an array to a string.
static string
toString
([array $array = null], [string $inner_glue = '='], [string $outer_glue = ' '], [boolean $keepOuterKey = false])
-
array
$array: The array to map.
-
string
$inner_glue: The glue (optional, defaults to '=') between the key and the value.
-
string
$outer_glue: The glue (optional, defaults to ' ') between array elements.
-
boolean
$keepOuterKey: True if final key should be kept.
Utility function to map an object or array to an array
static array
_fromObject
(mixed $item, boolean $recurse, string $regex)
-
mixed
$item: The source object or array
-
boolean
$recurse: True to recurse through multi-level objects
-
string
$regex: An optional regular expression to match on field names
Callback function for sorting an array of objects on a key
static integer
_sortObjects
(array &$a, array &$b)
-
array
&$a: An array of objects
-
array
&$b: An array of objects