Abstract Class JArrayHelper

Description

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

  • abstract:
  • since: 11.1

Located in /libraries/joomla/utilities/arrayhelper.php (line 19)


	
			
Variable Summary
 static mixed $sortCase
 static mixed $sortDirection
 static string $sortKey
 static mixed $sortLocale
Method Summary
 static array arrayUnique (array $myArray)
 static array fromObject (object $p_obj, [boolean $recurse = true], [string $regex = null])
 static array getColumn (array &$array, string $index)
 static mixed getValue (array &$array, string $name, [mixed $default = null], [string $type = ''])
 static array invert (array $array)
 static boolean isAssociative (array $array)
 static array pivot (array $source, [string $key = null])
 static array sortObjects (array &$a, mixed $k, [mixed $direction = 1], [mixed $caseSensitive = true], [mixed $locale = false])
 static void toInteger (array &$array, [mixed $default = null])
 static object The toObject (array &$array, [string $class = 'stdClass'])
 static string toString ([array $array = null], [string $inner_glue = '='], [string $outer_glue = ' '], [boolean $keepOuterKey = false])
 static array _fromObject (mixed $item, boolean $recurse, string $regex)
 static integer _sortObjects (array &$a, array &$b)
Variables
static mixed $sortCase (line 27)

Option to perform case-sensitive sorts.

  • var: Boolean or array of booleans.
  • since: 11.3
  • access: protected
static mixed $sortDirection (line 35)

Option to set the sort direction.

  • var: Integer or array of integers.
  • since: 11.3
  • access: protected
static string $sortKey (line 43)

Option to set the object key to sort on.

  • since: 11.3
  • access: protected
static mixed $sortLocale (line 51)

Option to perform a language aware sort.

  • var: Boolean or array of booleans.
  • since: 11.3
  • access: protected
Methods
static arrayUnique (line 595)

Multidimensional array safe unique test

static array arrayUnique (array $myArray)
  • array $myArray: The array to make unique.
static fromObject (line 173)

Utility function to map an object to an array

  • return: The array mapped from the given object
  • since: 11.1
  • access: public
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
static getColumn (line 243)

Extracts a column from an array of arrays or objects

  • return: Column of values from the source array
  • since: 11.1
  • access: public
static array getColumn (array &$array, string $index)
  • array &$array: The source array
  • string $index: The index of the column or name of object property
static getValue (line 277)

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

  • return: The value from the source array
  • since: 11.1
  • access: public
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)
static invert (line 364)

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' );

  • return: The inverted array.
  • since: 12.3
  • access: public
static array invert (array $array)
  • array $array: The source array.
static isAssociative (line 396)

Method to determine if an array is an associative array.

  • return: True if the array is an associative array.
  • since: 11.1
  • access: public
static boolean isAssociative (array $array)
  • array $array: An array to test.
static pivot (line 422)

Pivots an array to create a reverse lookup of an array of scalars, arrays or objects.

  • return: An array of arrays pivoted either on the value of the keys, or an individual key of an object or array.
  • since: 11.3
  • access: public
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.
static sortObjects (line 500)

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

  • return: The sorted array of objects
  • since: 11.1
  • access: public
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
static toInteger (line 63)

Function to convert array to integer values

  • since: 11.1
  • access: public
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
static toObject (line 100)

Utility function to map an array to a stdClass object.

  • return: object mapped from the given array
  • since: 11.1
  • access: public
static object The toObject (array &$array, [string $class = 'stdClass'])
  • array &$array: The array to map.
  • string $class: Name of the class to create
static toString (line 135)

Utility function to map an array to a string.

  • return: The string mapped from the given array
  • since: 11.1
  • access: public
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.
static _fromObject (line 196)

Utility function to map an object or array to an array

  • return: The array mapped from the given object
  • since: 11.1
  • access: protected
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
static _sortObjects (line 533)

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

Documentation generated on Tue, 19 Nov 2013 14:53:51 +0100 by phpDocumentor 1.4.3