public static
|
#
toInteger( array & $array, mixed $default = null )
Function to convert array to integer values
Function to convert array to integer values
Parameters
- $array
array - &$array The source array to convert
- $default
mixed - $default A default value (int|array) to assign if $array is not an array
Since
11.1
|
public static
object
|
#
toObject( array & $array, string $class = 'stdClass', boolean $recursive = true )
Utility function to map an array to a stdClass object.
Utility function to map an array to a stdClass object.
Parameters
- $array
array - &$array The array to map.
- $class
string - $class Name of the class to create
- $recursive
boolean - $recursive Convert also any array inside the main array
Returns
object - The object mapped from the given array
Since
11.1
|
public static
string
|
#
toString( array $array = null, string $inner_glue = '=', string $outer_glue = ' ', boolean $keepOuterKey = false )
Utility function to map an array to a string.
Utility function to map an array to a string.
Parameters
- $array
array - $array The array to map.
- $inner_glue
string - $inner_glue The glue (optional, defaults to '=') between the key and the value.
- $outer_glue
string - $outer_glue The glue (optional, defaults to ' ') between array elements.
- $keepOuterKey
boolean - $keepOuterKey True if final key should be kept.
Returns
string - The string mapped from the given array
Since
11.1
|
public static
array
|
#
fromObject( object $p_obj, boolean $recurse = true, string $regex = null )
Utility function to map an object to an array
Utility function to map an object to an array
Parameters
- $p_obj
object - $p_obj The source object
- $recurse
boolean - $recurse True to recurse through multi-level objects
- $regex
string - $regex An optional regular expression to match on field names
Returns
array - The array mapped from the given object
Since
11.1
|
protected static
array
|
#
_fromObject( mixed $item, boolean $recurse, string $regex )
Utility function to map an object or array to an array
Utility function to map an object or array to an array
Parameters
- $item
mixed - $item The source object or array
- $recurse
boolean - $recurse True to recurse through multi-level objects
- $regex
string - $regex An optional regular expression to match on field names
Returns
array - The array mapped from the given object
Since
11.1
|
public static
array
|
#
getColumn( array & $array, string $index )
Extracts a column from an array of arrays or objects
Extracts a column from an array of arrays or objects
Parameters
- $array
array - &$array The source array
- $index
string - $index The index of the column or name of object property
Returns
array - Column of values from the source array
Since
11.1
|
public 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
Utility function to return a value from a named array or a specified
default
Parameters
- $array
array - &$array A named array
- $name
string - $name The key to search for
- $default
mixed - $default The default value to give if no key found
- $type
string - $type Return type for the variable (INT, FLOAT, STRING, WORD, BOOLEAN, ARRAY)
Returns
mixed - The value from the source array
Since
11.1
|
public static
array
|
#
invert( array $array )
Takes an associative array of arrays and inverts the array keys to values
using the array values as keys.
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' );
Parameters
- $array
array - $array The source array.
Returns
array - The inverted array.
Since
12.3
|
public static
boolean
|
#
isAssociative( array $array )
Method to determine if an array is an associative array.
Method to determine if an array is an associative array.
Parameters
- $array
array - $array An array to test.
Returns
boolean - True if the array is an associative array.
Since
11.1
|
public static
array
|
#
pivot( array $source, string $key = null )
Pivots an array to create a reverse lookup of an array of scalars, arrays or
objects.
Pivots an array to create a reverse lookup of an array of scalars, arrays or
objects.
Parameters
- $source
array - $source The source array.
- $key
string - $key Where the elements of the source array are objects or arrays, the key to
pivot on.
Returns
array - An array of arrays pivoted either on the value of the keys, or an individual key
of an object or array.
Since
11.3
|
public static
array
|
#
sortObjects( array & $a, mixed $k, mixed $direction = 1, mixed $caseSensitive = true, mixed $locale = false )
Utility function to sort an array of objects on a given field
Utility function to sort an array of objects on a given field
Parameters
- $a
array - &$a An array of objects
- $k
mixed - $k The key (string) or an array of keys to sort on
- $direction
mixed - $direction Direction (integer) or an array of direction to sort in [1 =
Ascending] [-1 = Descending]
- $caseSensitive
mixed - $caseSensitive Boolean or array of booleans to let sort occur case sensitive or
insensitive
- $locale
mixed - $locale Boolean or array of booleans to let sort occur using the locale language
or not
Returns
array - The sorted array of objects
Since
11.1
|
protected static
integer
|
#
_sortObjects( array & $a, array & $b )
Callback function for sorting an array of objects on a key
Callback function for sorting an array of objects on a key
Parameters
- $a
array - &$a An array of objects
- $b
array - &$b An array of objects
Returns
integer - Comparison status
Since
11.1
See
|
public static
array
|
#
arrayUnique( array $myArray )
Multidimensional array safe unique test
Multidimensional array safe unique test
Parameters
- $myArray
array - $myArray The array to make unique.
Returns
array
Since
11.2
Link
|