@@ 117-127 (lines=11) @@ | ||
114 | * @param mixed $default The default value for unspecified keys. |
|
115 | * @return array Returns the array converted to long syntax. |
|
116 | */ |
|
117 | function array_quick(array $array, $default) { |
|
118 | $result = []; |
|
119 | foreach ($array as $key => $value) { |
|
120 | if (is_int($key)) { |
|
121 | $result[$value] = $default; |
|
122 | } else { |
|
123 | $result[$key] = $value; |
|
124 | } |
|
125 | } |
|
126 | return $result; |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Converts a quick array into a key/value form using a callback to convert the short items. |
|
@@ 136-146 (lines=11) @@ | ||
133 | * @param callable $callback The callback used to generate the default values. |
|
134 | * @return array Returns the array converted to long syntax. |
|
135 | */ |
|
136 | function array_uquick(array $array, callable $callback) { |
|
137 | $result = []; |
|
138 | foreach ($array as $key => $value) { |
|
139 | if (is_int($key)) { |
|
140 | $result[$value] = $callback($value); |
|
141 | } else { |
|
142 | $result[$key] = $value; |
|
143 | } |
|
144 | } |
|
145 | return $result; |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Load configuration data from a file into an array. |