Class Support_ArrayHelper

Description

Additional helper functions for working with arrays

Located in /support/lib/Support/ArrayHelper.php (line 14)


	
			
Method Summary
 static array exclude_sorted ( &$source,  &$exclude, array $source, array $exclude)
 static array intersect_sorted ( &$source,  &$incl, array $source, array $incl)
 static boolean is_associative (array &$array, [boolean $quick = true])
 static array kexclude_sorted ( &$source,  &$exclude, array $source, array $exclude)
 static array kintersect_sorted ( &$source,  &$incl, array $source, array $incl)
 static array merge_sorted ( &$array1,  &$array2, array $array1, array $array2)
Methods
static exclude_sorted (line 129)

Returns a new array containing all elements from source except any that are also present in exclude. Both input arrays must be sorted.

This function will reset the pointer for both arrays.

  • access: public
array exclude_sorted ( &$source,  &$exclude, array $source, array $exclude)
  • array $source: The source array
  • array $exclude: The collection of elements to exclude
  • &$source
  • &$exclude
static intersect_sorted (line 211)

Returns a new array containing only those values from source which are also present in incl. Both input arrays must be sorted.

This function will reset the pointer for both arrays.

  • access: public
array intersect_sorted ( &$source,  &$incl, array $source, array $incl)
  • array $source: The source array
  • array $incl: The collection of elements to include
  • &$source
  • &$incl
static is_associative (line 48)

Test an array to see if it is associative. Note that this resets the array pointer.

This test method has two modes. The default is quick mode, which examines only the first index if the array to see if it is numeric and begins at 0. The second mode examines all keys in the array until an out of sequence/non-numeric index is found or the end of the array is reached.

Potentially quick mode could mistake an array like this for a non-associative array:

  1.    array('Red''Orange''color'=>'Yellow''Green');

Turning off quick mode would correctly determine such an array is associative, but at the expense of additional processing for non-associative arrays.

  • access: public
boolean is_associative (array &$array, [boolean $quick = true])
  • array &$array: The array to test
  • boolean $quick: If true (default), quick mode is used for testing
static kexclude_sorted (line 173)

Similar to exlude_sorted, only the keys in source are compared to the values in exclude and only those key/value pairs whose keys are not in exlude are returned. The source array must be sorted by keys and the exclude array must be sorted by value.

This function will reset the pointer for the exclude array.

  • access: public
array kexclude_sorted ( &$source,  &$exclude, array $source, array $exclude)
  • array $source: The source array
  • array $exclude: The collection of elements to exclude
  • &$source
  • &$exclude
static kintersect_sorted (line 255)

Similar to intersect_sorted, only the keys in source are compared to the value in incl and only those key/value pairs whose keys are in incl are returned. The source array must be sorted by keys and the incl array must be sorted by value.

This function will reset the pointer for the incl array.

  • access: public
array kintersect_sorted ( &$source,  &$incl, array $source, array $incl)
  • array $source: The source array
  • array $incl: The collection of elements to include
  • &$source
  • &$incl
static merge_sorted (line 84)

Perform a basic two-way merge on pre-sorted input arrays.

This function will reset the pointer for both arrays.

  • return: An array containing the unique list of values from both arrays
  • access: public
array merge_sorted ( &$array1,  &$array2, array $array1, array $array2)
  • array $array1: The first array to merge
  • array $array2: The second array to merge
  • &$array1
  • &$array2

Documentation generated on Wed, 25 Apr 2012 09:46:39 -0700 by phpDocumentor 1.4.3