Misago\ActiveSupport\Array

Functions:

is_hash($arr)

Checks wether an array is a hash of key/value pairs or just a list of values.

array_collection($collection)

Simplifies handling of collections.

$collection = array_collection('a,b,  c, d');
$collection = array_collection(array('a', ' b', 'c ')); 

hash_merge_recursive()

Recursively merges hashes, overwriting non array/hash values.

array_sort_recursive(&$ary)

Recursively sorts arrays (skipping hashes).

array_to_string($ary)

Transforms an array with mixed keys (array and hash) into a full hash one.

Example:

$includes = array('tags', 'comments' => array('order' => 'created_at asc'));
$includes = linearize_options_tree($includes); 

$includes will be:

array(
  'tags' => array(),
  'comments' => array('order' => 'created_at asc'),
); 

function linearize_option_tree($ary) { $h = array(); foreach($ary as $k => $v) { if (is_int($k)) { $h[$v] = array(); } else { $h[$k] = is_array($v) ? linearize_options_tree($v) : $v; } } return $h; }