ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Arrays.php
Go to the documentation of this file.
1<?php
3
9class Arrays
10{
11
24 public static function arrayize($data, $index = 0)
25 {
26 return (is_array($data)) ? $data : array($index => $data);
27 }
28
29
39 public static function transpose($array)
40 {
41 if (!is_array($array)) {
42 return false;
43 }
44
45 $ret = array();
46 foreach ($array as $k1 => $a2) {
47 if (!is_array($a2)) {
48 return false;
49 }
50
51 foreach ($a2 as $k2 => $v) {
52 if (!array_key_exists($k2, $ret)) {
53 $ret[$k2] = array();
54 }
55 $ret[$k2][$k1] = $v;
56 }
57 }
58 return $ret;
59 }
60}
An exception for terminatinating execution or to throw for unit testing.
static arrayize($data, $index=0)
Put a non-array variable into an array.
Definition: Arrays.php:24
static transpose($array)
This function transposes a two-dimensional array, so that $a['k1']['k2'] becomes $a['k2']['k1'].
Definition: Arrays.php:39
$index
Definition: metadata.php:60
$ret
Definition: parser.php:6