FreenetIS
 All Classes Namespaces Functions Variables Pages
Static Public Member Functions | List of all members
arr Class Reference

Static Public Member Functions

static callback_string ($str)
 Return a callback array from a string, eg: limit[10,20] would become array('limit', array('10', '20'))
static rotate ($source_array, $keep_keys=TRUE)
 Rotates a 2D array clockwise.
static remove ($key, &$array)
 Removes a key from an array and returns the value.
static extract ($search, $keys)
 Extract one or more keys from an array.
static unshift_assoc (&$array, $key, $val)
 Because PHP does not have this function.
static map_recursive ($callback, $array)
 Because PHP does not have this function, and array_walk_recursive creates references in arrays and is not truly recursive.
static binary_search ($needle, $haystack, $nearest=FALSE, $sort=FALSE)
 Binary search algorithm.
static merge ()
 Emulates array_merge_recursive, but appends numeric keys and replaces associative keys, instead of appending all keys.
static overwrite ($array1)
 Overwrites an array with values from input array(s).
static range ($step=10, $max=100)
 Fill an array with a range of numbers.
static to_object (array $array, $class= 'stdClass', $recursively=TRUE)
 Recursively convert an array to an object.
static from_object ($object)
 Creates array from object.
static tolower ($array=array())
 Transforms array to lower.
static from_objects ($objects, $attribute= 'name')
 Converts array of objects to classic array in format: key = id of object, value = attributte.
static from_string ($string, $length, $offset=0)
 Creates array from string.
static variation ($array, $class)
 Returns variation of array.
static search ($needle, $haystack)
 Searchs in array.
static sort ($array)
 Sorts array, almost same as default PHP sort function, but it doesn't edit original array and returns new array.
static ksort ($array)
 Similar to sort, but sort by key.
static min_key ($array)
 Returns key with minimal value from array.
static max_key ($array)
 Returns key with maximal value from array.
static bool ()
 Return translated bool array (yes, no)
static rbool ()
 Return reverted translated bool array (no, yes)
static trim ($array=array(), $charlist= '')
 Remove values given by charlist (seperated by comma) from array.

Member Function Documentation

static arr::binary_search (   $needle,
  $haystack,
  $nearest = FALSE,
  $sort = FALSE 
)
static

Binary search algorithm.

Parameters
mixedthe value to search for
arrayan array of values to search in
booleanreturn false, or the nearest value
mixedsort the array before searching it
Returns
integer
static arr::bool ( )
static

Return translated bool array (yes, no)

Author
Ondřej Fibich
Returns
array
static arr::callback_string (   $str)
static

Return a callback array from a string, eg: limit[10,20] would become array('limit', array('10', '20'))

Parameters
stringcallback string
Returns
array
static arr::extract (   $search,
  $keys 
)
static

Extract one or more keys from an array.

Each key given after the first argument (the array) will be extracted. Keys that do not exist in the search array will be NULL in the extracted data.

Parameters
arrayarray to search
stringkey name
Returns
array
static arr::from_object (   $object)
static

Creates array from object.

Author
Michal Kliment
Parameters
mixed$object
Returns
array
static arr::from_objects (   $objects,
  $attribute = 'name' 
)
static

Converts array of objects to classic array in format: key = id of object, value = attributte.

Author
Michal Kliment
Parameters
$objectsarray of object to convert
$attributename of attributte to store as value of array
Returns
array
static arr::from_string (   $string,
  $length,
  $offset = 0 
)
static

Creates array from string.

Author
Michal Kliment
Parameters
string$string
integer$length
integer$offset
Returns
array
static arr::ksort (   $array)
static

Similar to sort, but sort by key.

Author
Michal Kliment
Parameters
type$array
Returns
type
static arr::map_recursive (   $callback,
  $array 
)
static

Because PHP does not have this function, and array_walk_recursive creates references in arrays and is not truly recursive.

Parameters
mixedcallback to apply to each member of the array
arrayarray to map to
Returns
array
static arr::max_key (   $array)
static

Returns key with maximal value from array.

Author
Michal Kliment
Parameters
type$array
Returns
type
static arr::merge ( )
static

Emulates array_merge_recursive, but appends numeric keys and replaces associative keys, instead of appending all keys.

Parameters
arrayany number of arrays
Returns
array
static arr::min_key (   $array)
static

Returns key with minimal value from array.

Author
Michal Kliment
Parameters
type$array
Returns
type
static arr::overwrite (   $array1)
static

Overwrites an array with values from input array(s).

Non-existing keys will not be appended!

Parameters
arraykey array
arrayinput array(s) that will overwrite key array values
Returns
array
static arr::range (   $step = 10,
  $max = 100 
)
static

Fill an array with a range of numbers.

Parameters
integerstepping
integerending number
Returns
array
static arr::rbool ( )
static

Return reverted translated bool array (no, yes)

Author
Ondřej Fibich
Returns
array
static arr::remove (   $key,
$array 
)
static

Removes a key from an array and returns the value.

Parameters
stringkey to return
arrayarray to work on
Returns
mixed value of the requested array key
static arr::rotate (   $source_array,
  $keep_keys = TRUE 
)
static

Rotates a 2D array clockwise.

Example, turns a 2x3 array into a 3x2 array.

Parameters
arrayarray to rotate
booleankeep the keys in the final rotated array. the sub arrays of the source array need to have the same key values. if your subkeys might not match, you need to pass FALSE here!
Returns
array
static arr::search (   $needle,
  $haystack 
)
static

Searchs in array.

Author
Michal Kliment
Parameters
string$needle
array$haystack
Returns
mixed
static arr::sort (   $array)
static

Sorts array, almost same as default PHP sort function, but it doesn't edit original array and returns new array.

Author
Michal Kliment
Parameters
array$array
Returns
array
static arr::to_object ( array  $array,
  $class = 'stdClass',
  $recursively = TRUE 
)
static

Recursively convert an array to an object.

Parameters
arrayarray to convert
Returns
object
static arr::tolower (   $array = array())
static

Transforms array to lower.

Author
Michal Kliment
Parameters
array$array
Returns
array
static arr::trim (   $array = array(),
  $charlist = '' 
)
static

Remove values given by charlist (seperated by comma) from array.

Author
Michal Kliment klime.nosp@m.nt@f.nosp@m.reene.nosp@m.tis..nosp@m.org
Parameters
type$array
type$charlist
Returns
type
static arr::unshift_assoc ( $array,
  $key,
  $val 
)
static

Because PHP does not have this function.

Parameters
arrayarray to unshift
stringkey to unshift
mixedvalue to unshift
Returns
array
static arr::variation (   $array,
  $class 
)
static

Returns variation of array.

Author
Michal Kliment
Parameters
array$array
integer$class
Returns
array

The documentation for this class was generated from the following file: