7 return (array_values($array) !== $array);
10 public static function getValue($array, $key, $pos) {
11 if (array_key_exists($key, $array)) {
14 $values = array_values($array);
15 if ($pos <
sizeof($values))
21 if (array_key_exists($key, $array)) {
22 $result = $array[$key];
23 if ($condition($result) ===
true)
26 $values = array_values($array);
27 foreach ($values as $val) {
28 if ($condition($val) ===
true)
35 if (array_key_exists($key, $array)) {
41 public static function implode($glue, $pieces) {
43 if (\is_array($glue)) {
44 $size = \sizeof($pieces);
46 for ($i = 0; $i < $size - 1; $i ++) {
47 $result .= $pieces[$i] . @$glue[$i];
49 $result .= $pieces[$size - 1];
52 $result = \implode($glue, $pieces);
58 if (\is_array(reset($array))) {
68 foreach ($sortedKeys as $key) {
69 if (\array_key_exists($key, $array)) {
70 $newArray[$key] = $array[$key];
79 if (isset($array[$from])) {
80 $out = array_splice($array, $from, 1);
81 array_splice($array, $to, 0, $out);
91 if (isset($array[$index1]) && isset($array[$index2])) {
92 $tmp = $array[$index1];
93 $array[$index1] = $array[$index2];
94 $array[$index2] = $tmp;
101 public static function modelArray($objects, $identifierFunction = NULL, $modelFunction = NULL) {
103 if (isset($modelFunction) ===
false) {
104 $modelFunction =
"__toString";
106 if (isset($identifierFunction) ===
false) {
107 foreach ($objects as $object) {
111 foreach ($objects as $object) {
119 if (\is_string($callback))
120 return \call_user_func(array(
124 else if (\is_callable($callback)) {
125 return $callback($object);
129 public static function count($array) {
130 if (\is_array($array)) {
131 return \sizeof($array);
138 foreach ($keys as $key) {
139 $assocKeys[$key] =
true;
141 return \array_diff_key($array, $assocKeys);
static moveElementTo(&$array, $from, $to)
static swapElements(&$array, $index1, $index2)
static getConditionalValue($array, $key, $condition)
static getValue($array, $key, $pos)
static removeByKeys($array, $keys)
static implode($glue, $pieces)
static callFunction($object, $callback)
static isAssociative($array)
static getDefaultValue($array, $key, $default=NULL)
static sortAssociative($array, $sortedKeys=array())
static modelArray($objects, $identifierFunction=NULL, $modelFunction=NULL)