1 | <?php |
||
12 | class Util |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Look for a deeo value in a nested data array. |
||
17 | * |
||
18 | * Given $data = ['one' => ['two' => ['three' => 55]], 'four' => []]; |
||
19 | * |
||
20 | * ```php |
||
21 | * getFromArrayByKey('one.two.three', $data) -> 55 |
||
22 | * getFromArrayByKey('one|two', $data, '|') -> ['three' => 55] |
||
23 | * getFromArrayByKey('four.five', $data) -> throws OutOfBoundsException |
||
24 | * ``` |
||
25 | * |
||
26 | * @param string $key |
||
27 | * @param array $data |
||
28 | * @param string $delimiter |
||
29 | * @return mixed|null |
||
30 | */ |
||
31 | public static function getFromArrayByKey(string $key, array $data, string $delimiter = '.') |
||
40 | |||
41 | /** |
||
42 | * Look for a deep value in a data array. |
||
43 | * |
||
44 | * Given $data = ['one' => ['two' => ['three' => 55]], 'four' => []]; |
||
45 | * |
||
46 | * ```php |
||
47 | * getArrayValueByKeys(['one','two','three'], $data) will return 55 |
||
48 | * getArrayValueByKeys(['four','five'], $data) will throw OutOfBoundsException |
||
49 | * ``` |
||
50 | * |
||
51 | * @param mixed $keys |
||
52 | * @param mixed $data passed by reference |
||
53 | * @return mixed |
||
54 | * @throws OutOfBoundsException if the key does not exist in data |
||
55 | */ |
||
56 | public static function getArrayValueByKeys(array $keys, &$data) |
||
71 | |||
72 | public static function getRequestHeadersFromServerArray(array $server_array) |
||
89 | } |
||
90 |