@@ 48-59 (lines=12) @@ | ||
45 | * @param $division |
|
46 | * @return array |
|
47 | */ |
|
48 | static public function getKeysByLastDivision(&$arr, $division) |
|
49 | { |
|
50 | ||
51 | $return = array(); |
|
52 | foreach ($arr as $key => $value) { |
|
53 | if (($pos = strrpos($key, $division)) !== false) { |
|
54 | $return[] = substr($key, $pos + 1); |
|
55 | } |
|
56 | } |
|
57 | ||
58 | return $return; |
|
59 | } |
|
60 | ||
61 | /** |
|
62 | * Convenience function to get keys containing a string |
|
@@ 87-99 (lines=13) @@ | ||
84 | * @param $division |
|
85 | * @return array |
|
86 | */ |
|
87 | static public function getKeysByFirstDivision(&$arr, $division) |
|
88 | { |
|
89 | ||
90 | $return = array(); |
|
91 | foreach ($arr as $key => $value) { |
|
92 | if (($pos = strpos($key, $division)) !== false) { |
|
93 | $return[] = substr($key, 0, $pos); |
|
94 | } |
|
95 | } |
|
96 | ||
97 | return $return; |
|
98 | ||
99 | } |
|
100 | ||
101 | /** |
|
102 | * Convenience function to rekey an array by a division |
|
@@ 110-121 (lines=12) @@ | ||
107 | * @param $division |
|
108 | * @return array |
|
109 | */ |
|
110 | static public function reKeyByLastKeyDivision(&$arr, $division) |
|
111 | { |
|
112 | ||
113 | $return = array(); |
|
114 | foreach ($arr as $key => $value) { |
|
115 | if (($pos = strrpos($key, $division)) !== false) { |
|
116 | $return[substr($key, $pos + 1)] = $value; |
|
117 | } |
|
118 | } |
|
119 | ||
120 | return $return; |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * Convenience function to rekey an array by a division |
|
@@ 133-145 (lines=13) @@ | ||
130 | * @param $division |
|
131 | * @return array |
|
132 | */ |
|
133 | static public function reKeyByFirstKeyDivision(&$arr, $division) |
|
134 | { |
|
135 | ||
136 | $return = array(); |
|
137 | foreach ($arr as $key => $value) { |
|
138 | if (($pos = strpos($key, $division)) !== false) { |
|
139 | $return[substr($key, 0, $pos)] = $value; |
|
140 | } |
|
141 | } |
|
142 | ||
143 | return $return; |
|
144 | ||
145 | } |
|
146 | ||
147 | /** |
|
148 | * Convenience function to filter arrays by their key containing a string |