@@ 37-51 (lines=15) @@ | ||
34 | * @param string $delimiter |
|
35 | * @return array |
|
36 | */ |
|
37 | public static function csplit($string, $delimiter = ',') |
|
38 | { |
|
39 | if (is_array($string)) { |
|
40 | return $string; |
|
41 | } |
|
42 | $res = []; |
|
43 | foreach (explode($delimiter, $string) as $k => $v) { |
|
44 | $v = trim($v); |
|
45 | if (strlen($v)) { |
|
46 | array_push($res, $v); |
|
47 | } |
|
48 | } |
|
49 | ||
50 | return $res; |
|
51 | } |
|
52 | ||
53 | public static function ksplit($string, $delimiter = ',') |
|
54 | { |
|
@@ 53-67 (lines=15) @@ | ||
50 | return $res; |
|
51 | } |
|
52 | ||
53 | public static function ksplit($string, $delimiter = ',') |
|
54 | { |
|
55 | if (is_array($string)) { |
|
56 | return $string; |
|
57 | } |
|
58 | $res = []; |
|
59 | foreach (explode($delimiter, $string) as $k => $v) { |
|
60 | $v = trim($v); |
|
61 | if (strlen($v)) { |
|
62 | $res[$v] = $v; |
|
63 | } |
|
64 | } |
|
65 | ||
66 | return $res; |
|
67 | } |
|
68 | ||
69 | /** |
|
70 | * Retrieves the values of an array elements or object properties with the given key or property name. |