ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Selection.php
Go to the documentation of this file.
1<?php
2
4
6
8{
22 public static function choose(...$chooseArgs)
23 {
24 $chosenEntry = Functions::flattenArray(array_shift($chooseArgs));
25 $entryCount = count($chooseArgs) - 1;
26
27 if (is_array($chosenEntry)) {
28 $chosenEntry = array_shift($chosenEntry);
29 }
30 if (is_numeric($chosenEntry)) {
31 --$chosenEntry;
32 } else {
33 return Functions::VALUE();
34 }
35 $chosenEntry = floor($chosenEntry);
36 if (($chosenEntry < 0) || ($chosenEntry > $entryCount)) {
37 return Functions::VALUE();
38 }
39
40 if (is_array($chooseArgs[$chosenEntry])) {
41 return Functions::flattenArray($chooseArgs[$chosenEntry]);
42 }
43
44 return $chooseArgs[$chosenEntry];
45 }
46}
An exception for terminatinating execution or to throw for unit testing.
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:583