FUEL CMS User Guide : Version 1.5.2


My Array Helper

Function Reference [+]

array_orderby()

An alternative array sorter that is a bit faster then array_sorter.

Returns

array

array_sorter($array, '$index', ['$order'='asc'], ['$nat_sort'=FALSE], ['$case_sensitive'=FALSE])

Array sorter that will sort on an array's key and allows for asc/desc order.

Returns

array

Parameters

(array) $array 
(string) $index 
(string) $order 
(boolean) $nat_sort 
(boolean) $case_sensitive 

object_sorter('$data', '$key', ['$order'='asc'])

Array sorter that will sort an array of objects based on an objects. property and allows for asc/desc order. Changes the original object.

Returns

NULL

Parameters

(mixed) $data 
(string) $key 
(string) $order 

options_list($values, ['$value'='id'], ['$label'='name'], ['$value_as_key'=FALSE])

Creates a key/value array based on an original array. Can be used in conjunction with the Form library class (e.g. $this->form->select('countries, option_list($options))).

Returns

array

Parameters

(array) $values 
(string) $value 
(string) $label 
(boolean) $value_as_key 

parse_string_to_array('$str')

Parses a string in the format of key1="val1" key2="val2" into an array.

Returns

array

Parameters

(string) $str 

array_group($array, '$groups')

Returns an array of arrays.

Returns

array

Parameters

(array) $array an array to be divided
(int) $groups number of groups to divide the array into

csv_to_array(['$filename'=''], ['$delimiter'=','], ['$header_row'=0], ['$length'=0])

Converts a .csv file to an associative array. Must have header row.

Returns

array

Parameters

(string) $filename file name
(string) $delimiter the delimiter that separates each column
(int) $header_row the index for where the header row starts
(int) $length must be greater then the maximum line length. Setting to 0 is slightly slower, but works for any length

array_get('$array', '$key', ['$default'=FALSE])

Return the value from an associative array or an object. credit: borrowed from Vanilla forums GetValueR function.

Returns

mixed The value from the array or object.

Parameters

(mixed) $array $array The array or object to search.
(string) $key $key The key or property name of the value.
(mixed) $default $default The value to return if the key does not exist.