1 | <?php |
||
3 | class HelperArray { |
||
4 | |||
5 | const ARRAY_REPLACE = 0; |
||
6 | const ARRAY_MERGE = 1; |
||
7 | |||
8 | /** |
||
9 | * Convert $delimiter delimited string to array |
||
10 | * |
||
11 | * @param mixed $string |
||
12 | * @param string $delimiter |
||
13 | 1 | * |
|
14 | 1 | * @return array |
|
15 | */ |
||
16 | public static function stringToArray($string, $delimiter = ',') { |
||
19 | |||
20 | /** |
||
21 | * Convert single value to array by reference |
||
22 | * |
||
23 | * @param mixed &$value |
||
24 | 1 | */ |
|
25 | 1 | public static function makeArrayRef(&$value, $index = 0) { |
|
28 | |||
29 | |||
30 | /** |
||
31 | * Convert single value to array |
||
32 | * |
||
33 | * @param mixed $value |
||
34 | 1 | * |
|
35 | 1 | * @return array |
|
36 | */ |
||
37 | 1 | public static function makeArray($value, $index = 0) { |
|
42 | 1 | ||
43 | /** |
||
44 | 1 | * Filters array by callback |
|
45 | * |
||
46 | 1 | * @param mixed $array |
|
47 | * @param callable $callback |
||
48 | * |
||
49 | 1 | * @return array |
|
50 | 1 | */ |
|
51 | public static function filter(&$array, $callback) { |
||
65 | 1 | ||
66 | /** |
||
67 | * Filter empty() values from array |
||
68 | * |
||
69 | * @param $array |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | public static function filterEmpty($array) { |
||
76 | |||
77 | /** |
||
78 | * @param string $string |
||
79 | * @param string $delimiter |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | public static function stringToArrayFilterEmpty($string, $delimiter = ',') { |
||
86 | |||
87 | /** |
||
88 | * @param mixed|array &$arrayOld |
||
89 | * @param mixed|array $arrayNew |
||
90 | * @param int $mergeStrategy - default is HelperArray::ARRAY_REPLACE |
||
91 | */ |
||
92 | public static function merge(&$arrayOld, $arrayNew = array(), $mergeStrategy = HelperArray::ARRAY_REPLACE) { |
||
109 | |||
110 | } |
||
111 |