-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayUtils.php
More file actions
41 lines (36 loc) · 797 Bytes
/
ArrayUtils.php
File metadata and controls
41 lines (36 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace LAG\Component\ArrayUtils;
/**
* Class ArrayUtils.
*
* @author lutangar
*/
class ArrayUtils
{
/**
* Return an imploded string from a multi dimensional array.
*
* @param string $glue
* @param array $array
*
* @return string
*/
public static function recursiveImplode($glue, array $array)
{
$return = '';
$index = 0;
$count = count($array);
foreach ($array as $piece) {
if (is_array($piece)) {
$return .= self::recursiveImplode($glue, $piece);
} else {
$return .= $piece;
}
if ($index < $count - 1) {
$return .= $glue;
}
++$index;
}
return $return;
}
}