class JArrayHelper


Located at : UKNOWVA_ROOT/libraries/joomla/utilities/arrayhelper.php

JArrayHelper is an array utility class for doing all sorts of odds and ends with arrays.

Methods

static void
toInteger(array $array, mixed $default = null)

Function to convert array to integer values

static object
toObject(array $array, string $class = 'stdClass')

Utility function to map an array to a stdClass object.

static string
toString(array $array = null, string $inner_glue = '=', string $outer_glue = ' ', boolean $keepOuterKey = false)

Utility function to map an array to a string.

static array
fromObject(object $p_obj, boolean $recurse = true, string $regex = null)

Utility function to map an object to an array

static array
getColumn(array $array, string $index)

Extracts a column from an array of arrays or objects

static mixed
getValue(array $array, string $name, mixed $default = null, string $type = '')

Utility function to return a value from a named array or a specified default

static boolean
isAssociative(array $array)

Method to determine if an array is an associative array.

static array
sortObjects($a, $k, $direction = 1, $casesensitive = true, $locale = false)

Utility function to sort an array of objects on a given field

static array
arrayUnique(array $myArray)

Multidimensional array safe unique test

Details

at line 31
static void toInteger(array $array, mixed $default = null)

Function to convert array to integer values

Parameters

array $array The source array to convert
mixed $default A default value (int|array) to assign if $array is not an array

Return Value

void

at line 58
static object toObject(array $array, string $class = 'stdClass')

Utility function to map an array to a stdClass object.

Parameters

array $array The array to map.
string $class Name of the class to create

Return Value

object The object mapped from the given array

at line 86
static string toString(array $array = null, string $inner_glue = '=', string $outer_glue = ' ', boolean $keepOuterKey = false)

Utility function to map an array to a string.

Parameters

array $array The array to map.
string $inner_glue
string $outer_glue
boolean $keepOuterKey True if final key should be kept.

Return Value

string The string mapped from the given array

at line 117
static array fromObject(object $p_obj, boolean $recurse = true, string $regex = null)

Utility function to map an object to an array

Parameters

object $p_obj The source object
boolean $recurse True to recurve through multi-level objects
string $regex An optional regular expression to match on field names

Return Value

array The array mapped from the given object

at line 186
static array getColumn(array $array, string $index)

Extracts a column from an array of arrays or objects

Parameters

array $array The source array
string $index The index of the column or name of object property

Return Value

array Column of values from the source array

at line 219
static mixed getValue(array $array, string $name, mixed $default = null, string $type = '')

Utility function to return a value from a named array or a specified default

Parameters

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)

Return Value

mixed The value from the source array

at line 285
static boolean isAssociative(array $array)

Method to determine if an array is an associative array.

Parameters

array $array An array to test.

Return Value

boolean True if the array is an associative array.

at line 311
static array sortObjects($a, $k, $direction = 1, $casesensitive = true, $locale = false)

Utility function to sort an array of objects on a given field

Parameters

$a
$k
$direction
$casesensitive
$locale

Return Value

array The sorted array of objects

at line 395
static array arrayUnique(array $myArray)

Multidimensional array safe unique test

Parameters

array $myArray

Return Value

array

See also

http://php.net/manual/en/function.array-unique.php