ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Arrays.php
Go to the documentation of this file.
1 <?php
2 namespace SimpleSAML\Utils;
3 
9 class 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 }
static transpose($array)
This function transposes a two-dimensional array, so that $a[&#39;k1&#39;][&#39;k2&#39;] becomes $a[&#39;k2&#39;][&#39;k1&#39;].
Definition: Arrays.php:39
static arrayize($data, $index=0)
Put a non-array variable into an array.
Definition: Arrays.php:24
$index
Definition: metadata.php:60
$ret
Definition: parser.php:6
$data
Definition: bench.php:6