File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -242,4 +242,14 @@ Validator::isstring('Hello world!');
242242
243243// This is valid because 'String' starts with uppercased letter.
244244Validator::isString('Hello world!');
245- ```
245+ ```
246+
247+ ### ` \Noname\Common\Arr `
248+
249+ A helper library for working with arrays.
250+
251+ #### Arr Methods
252+
253+ ##### ` Arr::flatten(array $array, string $separator = '.', string $prepend = '') : array `
254+
255+ Flatten an associative array using a custom separator.
Original file line number Diff line number Diff line change @@ -14,17 +14,17 @@ class Arr
1414 * By default this method will use a dot (.) as the separator.
1515 *
1616 * @param array $array
17- * @param string $prepend
1817 * @param string $separator
18+ * @param string $prepend
1919 * @return array
2020 */
21- public static function flatten (array $ array , string $ prepend = '' , string $ separator = '. ' ): array
21+ public static function flatten (array $ array , string $ separator = '. ' , string $ prepend = '' ): array
2222 {
2323 $ flatArray = [];
2424
2525 foreach ($ array as $ key => $ value ) {
2626 if (is_array ($ value ) && !empty ($ value )) {
27- $ flatArray += self ::flatten ($ value , $ prepend . $ key . $ separator , $ separator );
27+ $ flatArray += self ::flatten ($ value , $ separator , $ prepend . $ key . $ separator );
2828 } else {
2929 $ flatArray [$ prepend . $ key ] = $ value ;
3030 }
You can’t perform that action at this time.
0 commit comments